How to read text file by particular line separator character?

后端 未结 9 2019
独厮守ぢ
独厮守ぢ 2020-12-03 00:58

Reading a text file using streamreader.

using (StreamReader sr = new StreamReader(FileName, Encoding.Default))
{
     string line = sr.ReadLine();
}
<         


        
9条回答
  •  执念已碎
    2020-12-03 01:33

    According to the documentation:

    http://msdn.microsoft.com/en-us/library/system.io.streamreader.readline.aspx

    A line is defined as a sequence of characters followed by a line feed ("\n"), a carriage return ("\r"), or a carriage return immediately followed by a line feed ("\r\n").

    By default the StreamReader ReadLine method will recognise a line by both/either \n or \r

提交回复
热议问题