开发者

What is the difference between File.ReadAllLines() and File.ReadAllText()?

开发者 https://www.devze.com 2023-01-02 07:37 出处:网络
What is the difference between File.ReadAllLines开发者_运维问答() and File.ReadAllText()?ReadAllLines returns an array of strings. Each string contains a single line of the file.

What is the difference between File.ReadAllLines开发者_运维问答() and File.ReadAllText()?


ReadAllLines returns an array of strings. Each string contains a single line of the file.

ReadAllText returns a single string containing all the lines of the file.


File.ReadAllText() returns one big string containing all the content of the file while File.ReadAllLines() returns string array of lines in the file.

Keep in mind that in case of ReadAllText "The resulting string does not contain the terminating carriage return and/or line feed."

More details are available at remarks section of File.ReadAllText Method and File.ReadAllLines Method.


ReadAllText reads it all in as one string, ReadAllLines reads it in as a StringArray.

0

精彩评论

暂无评论...
验证码 换一张
取 消