3 options:
Main
if you declare your Main
method to return int
.Environment.Exit(code)
.Environment.ExitCode = -1;
. This will be used if nothing else sets the return code or uses one of the other options above).Depending on your application (console, service, web app, etc) different methods can be used.