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?
You can use Environment. Exit(0) and Application. Exit .
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.
Pressing F5 then press Ctrl-C to terminate, the console always close whether the option is checked or not.
Environment.Exit
and Application.Exit
Environment.Exit(0)
is cleaner.
http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With