Bug in the File.ReadLines(..) method of the .net framework 4.0

后端 未结 7 1415
渐次进展
渐次进展 2021-01-11 16:31

This code :

IEnumerable lines = File.ReadLines(\"file path\");
foreach (var line in lines)
{
    Console.WriteLine(line); 
}
foreach (var line          


        
7条回答
  •  独厮守ぢ
    2021-01-11 16:35

    It isn't a bug. But I believe you can use ReadAllLines() to do what you want instead. ReadAllLines creates a string array and pulls in all the lines into the array, instead of just a simple enumerator over a stream like ReadLines does.

提交回复
热议问题