Why do we need Environment.Exit() in C#?
10:42 27 Dec 2025

Why is Environment.Exit(0) used, and in which condition is it appropriate to use this? In my case, I'm using it in a switch case code snippet:

case "0":
    closeApp = true;
    Console.WriteLine("Closing Application. Goodbye!");
    Environment.Exit(0);

What's the difference between Environment.Exit and return 0?

c#