This should be straightforward. I just need to simply exit my commandline c# program - no fancy stuff.
Should I use
Environment.Exit();
or
this.Close();
or something else?
In computing, exit is a command used in many operating system command-line shells and scripting languages. The command causes the shell or program to terminate.
Hold the Ctrl button and press the C key at the same time. It sends the SIGKILL signal to the running program to force quit the command.
Ctrl + C should stop a program running from the command prompt, similar to linux.
just return from the Main
method.
Edit:
if you really have lost the flow and want to exit from anywhere in the application (like inside any method called by Main), you can use:
Environment.Exit(0);
remember that normally you should return 0 to the calling process (OS) when everything went fine and you return a non zero value if an error happened and execution did not go as smooth as should have been.
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