Console Applications

  • Thread starter Thread starter clintonG
  • Start date Start date
clintonG said:
When running a console application through Visual Studio what's the best
method to keep the Window open so I can read "Hello World?"

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

If you are just testing, you can run the app in the debug mode. This will
display a "Press any key to continue..." method. If you don't want this
message, or are running in non-debugger, you can just place a line at the
end of the Main() method that waits for a character to be pressed...

[STAThread()]
public static void Main(params string[] Args)
{
Console.WriteLine("Hello World");
Console.ReadLine();
}

HTH,
Mythran
 
Console.Readline();

which waits for a keypress so you form remains open until you press enter.
 
clintonG said:
When running a console application through Visual Studio what's the best
method to keep the Window open so I can read "Hello World?"

Put a Console.ReadLine() at the end of your Main method.

-- Barry
 
I usually do this:
(which 1000 other people have said already)

Console.WriteLine (" Press Enter To Exit ");
Console.ReadLine();


That's how all my console apps end.
 
Back
Top