MrDatabase MrDatabase - 1 month ago 9
C# Question

How do I specify the exit code of a console application in .NET?

I have a trivial console application in .NET. It's just a test part of a larger application. I'd like to specify the "exit code" of my console application. How do I do this?

Answer

You can return it from Main if you declare your Main method to return int, or call Environment.Exit(code).