问题
I want to quit my Console Application, I have tried following commands:
Enviroment.Exit(0);
Application.Exit();
But it leads to Press any key to continue . . .. How could I exit my application without waiting any key?
回答1:
This only appears when you're running it from within Visual Studio itself, but only when running it without attaching a debugger (ctrl+F5 in most cases). Try actually running the built .exe in your Bin folder and observe the behavior of your application that way.
回答2:
Here's a demo console application:
static void Main(string[] args)
{
Environment.Exit(0);
}
The app exits without any such warning.
来源:https://stackoverflow.com/questions/28895106/exit-console-without-waiting-press-any-key-to-continue