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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
return;in yourMainmethod.If you aren’t in the main method when you decide to exit the program, you need to return from the method that Main method currently executes.
Example:
This is not really an example of good overall design of a console application, but it illustrates the point.