Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command to close an application of console?

I need to close the console when the user selects a menu option.

I tried using close() but it did not work..

how can I do this?

like image 720
ale Avatar asked Apr 15 '11 21:04

ale


People also ask

How do you end a console program in C#?

You can use Environment. Exit(0) and Application. Exit .

How do I exit Java console?

exit() method exits current program by terminating running Java virtual machine. This method takes a status code. A non-zero value of status code is generally used to indicate abnormal termination.

How do I close the console in Visual Studio?

Pressing F5 then press Ctrl-C to terminate, the console always close whether the option is checked or not.


2 Answers

Environment.Exit and Application.Exit

Environment.Exit(0) is cleaner.

http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx

like image 57
Priyank Avatar answered Sep 23 '22 18:09

Priyank


By close, do you mean you want the current instance of the console app to close, or do you want the application process, to terminate? Missed that all important exit code:

Environment.Exit(0); 

Or to close the current instance of the form:

this.Close(); 

Useful link.

like image 22
Robert Avatar answered Sep 19 '22 18:09

Robert