What is the command to exit a console application in C#?
There are several ways to exust a console application in C#: You can useEnvironment.Exit(0);
and Application.Exit
Example
using System;
public class Example
{
public static void Main()
{
for(int i = 0 ; i< 10000000; i ++){
if(i == 10){
Console.WriteLine("Existing App when we reach i = 10");
Environment.Exit(0);
}
}
}
}
Output
Existing App when we reach i = 10