可悲的是没有,但如果你调试 - >不开始调试Ctrl + F5键它将使这种效果。
很明显,你可以在你的程序的末尾添加
Console.Write("\nPress Any Key to Continue");
Console.Readkey();
。
如果你想成为(几乎)确保您的代码将始终显示提示:
AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
{
Console.Write("\nPress Any Key to Continue");
Console.ReadKey();
};
把这些线在你Main()
方法的开始。
但我认为这有点过分了:-)它安装了一个退出处理程序,它会在退出时要求一个键。现在
,如果你想真的真的太过火和表演,你可以去多达11个:
if (Debugger.IsAttached)
{
AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
{
Console.Write("\nPress Any Key to Continue");
Console.ReadKey();
};
}
这将要求只有在调试器附着(即使这些线必须是关键放在Main()
方法的开头,它们替换了其他版本)。与Start Without Debugging
调试器不是附加,所以Visual Studio将显示其提示而不是你的。
(而不是使用AppDomain.CurrentDomain.ProcessExit
的,你可以有一个try...finally
块保护整个Main()方法,并在最后放Console.*
,但是这一点也不好笑:-))
它是因为您的程序在完成后退出 – Rohit