Pause Output From a Command Line Application in .NET Debug Mode

Contributor Icon Contributed by johnnythawte Date Icon December 22, 2006  
Tag Icon Tagged: C programming

If you are writing a command line application in .NET, you might notice that the application closes immediately if you haven’t set a breakpoint. This recipe shows you the one line method to keep the application open so you can see the output.


Typically when you are writing to the console, you use the Console.Write() method, but there is also a Read method to go along with it.

If you place this line of code in your application, it will pause and wait for a keystroke before continuing:
Console.ReadLine();

If you are using Visual Basic instead of C#, just omit the semicolon.

Previous recipe | Next recipe |
 

 
close Reblog this comment
blog comments powered by Disqus