Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways of console pausing

Tags:

c#

console

As I'm new to C#, I searched Google for various stuff which I used to use in C++. One of them is a pause possibility in a console app.

A lot of people suggested different ways like

System.Console.ReadKey(true);
System.Console.WriteLine();

Others even showed self-made functions which 'should' be more efficient than others. And that's a real headache to decide which one is a better solution.

Could anyone give any examples of how C# interpret them and which way should be the most efficient?

like image 369
RnD Avatar asked Dec 01 '12 17:12

RnD


1 Answers

Run the program using any of the following methods:

  1. ctrl + F5

OR as Rajesh suggested

  1. Console.ReadKey() //pauses for any key
  2. Console.ReadLine() //pauses for enter key
like image 81
static_cast Avatar answered Nov 12 '22 08:11

static_cast