Is there a maximum for the read in line of File.ReadLines()?

亡梦爱人 提交于 2020-01-06 03:07:16

问题


What happen if the file has very-long line(s)?

Is there any limitation to how long a line is to iterate each of

File.ReadLines()

回答1:


I did not see any info regarding maximum length for File.ReadLines(). I would imagine the only limitation is that a string can't exceed 2GB, which is roughly 1 billion characters. That was listed on the MSDN page for string.




回答2:


Since the documentation doesn't say anything about the limit of a line read from a file, the limit then becomes that of a regular string.

A string, whose length is given by a signed int, can have up to 2^31 characters (2,147,483,647).

However, since objects are also capped at 2GB, 2^31 characters is not the actual limit. According to the docs, you can fit about 1 billion characters in those 2GB.



来源:https://stackoverflow.com/questions/24738057/is-there-a-maximum-for-the-read-in-line-of-file-readlines

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!