From outside of the application, is there any difference between
...
Environment.Exit(2)
and
static int Main()
{
...
return 2;
}
?
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.
The most obvious difference is that you can call Environment.Exit from anywhere in your code. Aside from that:
Environment.Exitwill take down the process anyway.Environment.Exitterminates the process without unwinding the stack and executing finally blocks (at least according to my experiments). Obviously when you return fromMainyou’re already at the top level as far as managed code is concerned.Environment.Exitdemands the appropriate security permission, so won’t work for less trusted apps.Having seen the question update, I’m not entirely sure what you mean. In both cases the process will just exit with a code of 2…