views:

697

answers:

3

Most programming books will tell you to use Console.ReadKey() to pause the console, but is there a better alternative?

Console.WriteLine("Press any key to continue.");
Console.ReadKey();
+10  A: 

You haven't actually told us what you wish to achieve.

If you wish to stop the output until the user chooses to continue, then you're not really going to get much better than just waiting for a key to be pressed using Console.ReadKey. If you just want to pause the output for a certain amount of time, you can use the Thread.Sleep method, which doesn't require any human invtervention.

IRBMe
Right on the money.
JoshJordan
Actually, was just waiting for a key to be pressed. Thanks, this answers my question.
M4dRefluX
Fair enough, I guess!
IRBMe
A: 

Absurd thing if you are trying to use to suspend the execution of your program as it with c/cplusplus with getch or something.

adatapost
A: 

How about Console.ReadLine() :)

Abhijeet Patel