Tips & Tricks: Run Console Applications in Visual Studio .Net that doesn’t exit when finished


Most of you might already know this little trick, but for those of you that don’t know it yet it’s very handy.

We often create small console applications to test some piece of code or implementation. We will often use the Console.WriteLine and Console.Write to display the results. Now when you debug your console application it will exit when the code is executed which will make it difficult for you to review the results that have been written to the console. One solution is to add the line Console.ReadLine at the end of the code so that the application waits for the user to press enter and then it will exit.

Another faster solution is instead of pressing F5 you can also press CTRL + F5. Using this method your application will be started and when the code is executed it will put the Console into a Pauze. For those of you that are familiar with Batch files it’s the same effect as adding a pauze keyword.