Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   Press any key to continue... (http://www.programmingforums.org/showthread.php?t=13158)

357mag May 16th, 2007 1:11 AM

Press any key to continue...
 
When you write a console program in C#, after I read the output and I'm done looking at the output, I'd like the "Press any key to continue..." message to be displayed at the bottom, similar to the way it's displayed in Visual C++. But I don't know if this is possible. My experience so far has been that to close the console window, you must hit only the Enter key. Is there a way to close the window by hitting any key?

crawforddavid2006 May 16th, 2007 1:28 AM

put this at the end, or where ever you want it to say "Press any key to continue..."

:

                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();


Wizard1988 May 16th, 2007 9:38 AM

Any key? Where is the any key?

357mag May 16th, 2007 3:55 PM

Thanks. I will try it out. Can I ask though about the ReadKey()funtion? What does it do? Does it just read a keypress(any key) and then when the user presses any key the program will terminate? Does it return a true or false value to the program or something? If you could just provide a little explanation so I can understand and add some comments to my program. I'm the kind that wants to understand what every single line is doing.

DaWei May 16th, 2007 4:22 PM

Have you considered looking it up?

crawforddavid2006 May 16th, 2007 4:37 PM

Quote:

Originally Posted by 357mag (Post 127924)
Thanks. I will try it out. Can I ask though about the ReadKey()funtion? What does it do? Does it just read a keypress(any key) and then when the user presses any key the program will terminate? Does it return a true or false value to the program or something? If you could just provide a little explanation so I can understand and add some comments to my program. I'm the kind that wants to understand what every single line is doing.

It waits until a key is pressed, and then moves on to the next step. It can also be used for char variables too if i'm not mistaken

ReggaetonKing May 16th, 2007 5:10 PM

If you are unsure about a certain function or method that you use in C# code, enter "whatevermethodname() in C#" in your favorite search engine and it should give you an accurate result.

Here's a link to see more resources for C#:
http://msdn2.microsoft.com/en-us/lib...62(VS.80).aspx


All times are GMT -5. The time now is 12:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC