How to exit a program with an exit code in C#?
In java it would be System.exit(int code);
views:
101answers:
2
+8
A:
Either:
- Declare your
Main
function as returningint
, and return a value from it, or - Call
Environment.Exit(int)
Returning a value from Main
is a little nicer than exiting the process in the middle of a method, but this is presumably the same advice that applies to Java, C or C++.
Tim Robinson
2010-08-20 08:49:13
FYI, the docs for the possible return values for Main - http://msdn.microsoft.com/en-us/library/0fwzzxz2.aspx
Richard Szalay
2010-08-20 08:50:44
+1 Far better answer than mine was.
fletcher
2010-08-20 09:05:14