且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

输出屏幕在 C# 控制台应用程序中突然消失?

更新时间:2023-02-19 19:42:33

程序立即关闭,因为没有任何东西阻止它关闭.在return 0;处插入断点或在return 0;前添加Console.Read();,防止程序关闭.

The program immediately closes because there's nothing stopping it from closing. Insert a breakpoint at return 0; or add Console.Read(); before return 0; to prevent the program from closing.

完成程序后,按 Ctrl+F5(不带调试).这将在关闭窗口之前提示,这是你想要什么.

After you are done with your program, press Ctrl+F5 ( Run without debugging). This will prompt before closing the window and this is what you want.

在最后使用这一行

Console.ReadKey();