方法一:
using (StreamReader srr = new StreamReader(@"D:\Users\Desktop\Mytest.txt"))//文件内容:三个字
//符串,每个字符串占一行
{
string xx = string.Empty;
while ((xx=srr.ReadLine())!=null)
{
Console.WriteLine(xx);
}
}
//返回:
//ni
//chou
//sha
方法二:
using (StreamReader srr = new StreamReader(@"D:\Users\Desktop\Mytest.txt"))//文件内容三个字
//符串,每个占一行
{
while ( srr.ReadLine() != null)
{
string str = srr.ReadLine();
Console.WriteLine(str);
}
}
//返回:
//chou
//
// (这里还多了两个空白行)
同一个TXT文件,返回不一样,为啥呢?