Using Environment.ExitCode versus returning int from Main
I am planning to use the return code of the C# executable in one of my shell script. I have two options: Returning a int value from the main method class MainReturnValTest { static int Main() { //... return 0; } } (OR) Using Environment.Exit with an exit code class MainReturnValTest { static void Main() { //... Enviroment.Exit(exitCode); } } Is it fine to use any of the above ways to return value from the executable? Or is one of them preferred over other? Environment.Exit() is a rude abort. It instantly terminates the process. Use it only when you detect a gross failure, it is appropriate in