Reads the next character from Console.In, which is set to the system's standard input stream by default.
[Visual Basic] Public Shared Function Read() As Integer [C#] public static int Read(); [C++] public: static int Read(); [JScript] public static function Read() : int;
The next character from the input stream, or negative 1 if no more characters are available.
Exception Type | Condition |
---|---|
IOException | An I/O error occured. |
[C#]
int i; char c; while (true) { i = Console.Read (); if (i == -1) break; c = (char) i; Console.WriteLine ("Echo: {0}", c); } Console.WriteLine ("Done"); return 0; }