问题
I would like to read lines from console until EOF. I came up with this solution but I don't know if it is correct one.
String line;
while ((line = Console.ReadLine()) != null) {
}
回答1:
Console.ReadLine Method () returns :
The next line of characters from the input stream, or null if no more lines are available.
Question : I came up with this solution but I don't know if it is correct one!
Answer : Yes, your code is correct.
Also, please go through the added link in the answer to know more about its uses.
来源:https://stackoverflow.com/questions/36526669/how-to-detect-eof-on-the-console-in-c-what-does-console-readline-returns-upo