Search code examples
c#console

How to check if the standard input is empty?


I need to know if there are any input symbols in the standard input.

But I don't know how to check such a condition.

As I understand I can't use Console.Read() because it will actually read the next input symbol.


Solution

  • I think you could use Console.In as an System.IO.TextReader and use the Peek()-Method:

    if(Console.In.Peek() == "I don't know what it will be...")
    { /* Do something */ }