Exit console without waiting press any key to continue…

瘦欲@ 提交于 2019-12-12 12:47:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!