问题
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