Method Console.Read()

  • Thread starter Thread starter Piotr
  • Start date Start date
P

Piotr

Hi

I find error:

method System.Console.Read() should read one character from input stream,
not full line characters (end line==press enter). It can't be equal to
System.Console.ReadLine().

Method System.Console.ReadLine() work good, but System.Console.Read() should
not wait for enter, after pressing a key!

P.M.
 
In order for Console.Read to have the ability to read, the user must send
its data to the console and the only way to do that is to hit ENTER.

Console.Read will read the next character from the input stream. So, if the
user types "ABC" and hits ENTER, Console.Read will read the "A", whereas
Console.ReadLine will read "ABC" and the carriage return. The main thing is
that we need to have a way to tell the console that we are done providing
input, so both Read and ReadLine must wait for ENTER.
 
I understand it, but Console.Read read line and get first character.
I think, that Console.Read should not wait for ENTER.
 
Think about it for a second... You are dealing with event driven code. How
in the world is the Console window to know what code you have written for it
behind the scenes? It MUST stay open until the user has indicated that they
are done using it (ENTER).
 
Back
Top