.NET Framework Bookmark and Share   
 index > .NET Base Class Library > "press any key to continue"
 

"press any key to continue"

I'm doing a small console application ,and I wanted to wait for the key to press an key to continue(end the program),I wa s recommended the "Console.Read();",but when used it,it waited only for the "enter" and it writes all the other charachters on console,so I understood that this function just only takes the input streams and put it on consol,then why on pressing enter it goes out of the program ?,thanks in advance
YOMNaM

Console.ReadKey(false);

It would behoove you to have the link to the API documentation handy.

http://msdn2.microsoft.com/en-us/library/aa388745.aspx

eradicator

hi,yoyo_houda

I think eradicator's answer is a good solution for implementing the function you described above.

And regarding the question "why on pressing enter it goes out of the program ?"I think you can get answer from the following remarks about the System.Console.Read function.

The Read method blocks its return while you type input characters; it terminates when you press the Enter key. Pressing Enter appends a platform-dependent line termination sequence to your input (for example, Windows appends a carriage return-linefeed sequence). Subsequent calls to the Read method retrieve your input one character at a time. After the final character is retrieved, Read blocks its return again and the cycle repeats.

for detail information,you canvisit: http://msdn2.microsoft.com/en-us/library/system.console.read.aspx

Yan-Fei Wei

Console.ReadKey(false);

It would behoove you to have the link to the API documentation handy.

http://msdn2.microsoft.com/en-us/library/aa388745.aspx

eradicator

hi,yoyo_houda

I think eradicator's answer is a good solution for implementing the function you described above.

And regarding the question "why on pressing enter it goes out of the program ?"I think you can get answer from the following remarks about the System.Console.Read function.

The Read method blocks its return while you type input characters; it terminates when you press the Enter key. Pressing Enter appends a platform-dependent line termination sequence to your input (for example, Windows appends a carriage return-linefeed sequence). Subsequent calls to the Read method retrieve your input one character at a time. After the final character is retrieved, Read blocks its return again and the cycle repeats.

for detail information,you canvisit: http://msdn2.microsoft.com/en-us/library/system.console.read.aspx

Yan-Fei Wei

You can use google to search for other answers

Custom Search

More Threads

• Avoid the Bcc from mail sending
• WMI from C# Error
• WndProc ..Constants as only Messages??
• double exe
• WMI pathes
• The program to get active File Names from Process is OK in 32-bit OS, but can't run in 64-bit OS.
• timer a cpu hog??
• Querying a Thread
• encryption
• Enumerating Sound Devices