Steven DeWitt
Steven DeWitt

Reputation: 1859

Is there a better alternative to Console.ReadKey()?

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();

Upvotes: 2

Views: 4857

Answers (3)

IRBMe
IRBMe

Reputation: 4425

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 intervention.

Upvotes: 15

Steven
Steven

Reputation: 120

system("pause");

does the same thing

Upvotes: -2

Abhijeet Patel
Abhijeet Patel

Reputation: 6878

How about Console.ReadLine() :)

Upvotes: 2

Related Questions