1
可以說我有一個Test.csv文件,該文件是C#字符串列表讀取單個元素,Console.Read()問題
Screen Name,Tweet ID,Dates,Tweets
OilGasMalaysia,5.21E+17,10/13/2014,Dropping Oil Prices Send Shockwaves Through Energy Sector - http://t.co/2dne6NGwRE http://t.co/hRUXjEQGCz
OilBRK,5.22E+17,10/13/2014,Oil prices down in Asian trade as weak demand weighs: Oil prices fell in Asian trade Monday on growi... http://t.co/yuL4D0FPx7 #Oil #BRK
OilBRK,5.22E+17,10/13/2014,Oil prices down in Asian trade as weak demand weighs: SINGAPORE: Oil prices fell in Asian trade Mond... http://t.co/RNBIRiQCu3 #Oil #BRK
OilBRK,5.22E+17,10/13/2014,Oil price down again on growth fears: Global oil prices fall again with Brent crude at a near four-y... http://t.co/AHUrTYORK2 #Oil #BRK
OilBRK,5.22E+17,10/13/2014,Oil heads for four-year low on Saudi output signal: Brent crude oil fell below $88 a barrel on Monda... http://t.co/O4JUbdFQ5o #Oil #BRK
我有下面的程序,我想用Test.csv StreamReader的
加載static void Main(string[] args)
{
List<string> CsvFile = new List<string>();
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("Test.csv");
while ((line = file.ReadLine()) != null)
{
CsvFile.Add(line);
// Console.WriteLine(line);
counter++;
//Console.ReadLine();
}
file.Close();
for (int i = 0; i < CsvFile.Count; i++)
{
Console.Write(CsvFile[i].ToString() + "\n");
Console.Read();
}
}
每件事情都很好,文件正在加載到內存中,但是當它進入for循環時,每兩個元素都顯示在一行中,問題與Console.Read()相關。
問題: 如何顯示下一個單個元素當用戶使用循環按鍵時。
謝謝。