By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,775 Members | 1,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,775 IT Pros & Developers. It's quick & easy.

Console Applications

P: n/a
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/
May 16 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Op**************@TK2MSFTNGP04.phx.gbl...
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

May 16 '06 #2

P: n/a
Console.ReadLine();

will keep the console window open until you press Enter.

======================
Clive Dixon
Digita Ltd. (www.digita.com)
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Op**************@TK2MSFTNGP04.phx.gbl...
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/

May 16 '06 #3

P: n/a
Console.Readline();

which waits for a keypress so you form remains open until you press enter.

--
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> schrieb im
Newsbeitrag news:Op**************@TK2MSFTNGP04.phx.gbl...
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/

May 16 '06 #4

P: n/a
just add:

Console.ReadLine();

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le
message de news: Op**************@TK2MSFTNGP04.phx.gbl...
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/

May 16 '06 #5

P: n/a
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote:
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
May 16 '06 #6

P: n/a


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.


"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Op**************@TK2MSFTNGP04.phx.gbl...
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/

May 16 '06 #7

P: n/a
Thanks to all 100 of you :-)

<%= Clinton Gallagher

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:Op**************@TK2MSFTNGP04.phx.gbl...
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/

May 16 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.