ReSharper says Console.ReadLine () returns null

I noticed that ReSharper offers me to check Console.ReadLine()for null. I don’t understand why, because as far as I know, the method returns ""even if you click enteron the console and do not enter a character.

I am using VS 2015 with the 3rd update, C # 6, .NET 4.6.1, ReSharper 10.

enter image description here

+4
source share
3 answers

The documentation states that a null return value is part of the contract for this method:

The next line of characters from the input stream or null if no more lines are available .

And give an example:

Ctrl + Z , , null.

TextReader, Console.In, Console.SetIn. TextReader null ReadLine.

+4

Console.ReadLine() null, Ctrl + Z.

MSDN:

Ctrl + Z , , null. ReadLine .

+5

MSDN, , Console.ReadLine() null, , .

0

All Articles