MrDatabase MrDatabase - 1 year ago 90
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download