Console Applications
-
In Visual Studio 2008 when writing a console application for C# in Debug you were able to click 'start without debugging' to view the results of your program then 'press any key to continue'. Visual Studio 2010 (beta 2) does not offer that option. How do you overcome this?
-
In Visual Studio 2008 when writing a console application for C# in Debug you were able to click 'start without debugging' to view the results of your program then 'press any key to continue'. Visual Studio 2010 (beta 2) does not offer that option. How do you overcome this?
Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to
Console.Readline();
at the end of your Main function. This will keep your console window open until you press a key. for example:static void Main(string\[\] args) { //Do Work Console.Write("press any key to continue"); Console.ReadLine(); //prevents console window from closing. }
Hope that Helps!
-
Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to
Console.Readline();
at the end of your Main function. This will keep your console window open until you press a key. for example:static void Main(string\[\] args) { //Do Work Console.Write("press any key to continue"); Console.ReadLine(); //prevents console window from closing. }
Hope that Helps!
-
Well, if you're concerned that your console window will close too quickly by running it with debugging (i.e. without prompting 'press any key to continue'). You can simply add a call to
Console.Readline();
at the end of your Main function. This will keep your console window open until you press a key. for example:static void Main(string\[\] args) { //Do Work Console.Write("press any key to continue"); Console.ReadLine(); //prevents console window from closing. }
Hope that Helps!
-
Either one will work. The point is to have the application wait for input before continuing.
I know the language. I've read a book. - _Madmatt