C# 调试HelloWorld 闪退

2025-06-14 09:28:52

程序运行结束是会退出的,打印完HelloWorld之后因为没有其他任务了,所以就退出了,又因为打印速度很快,所以我们会看到一个一闪而过的黑窗。 加入以下代码,程序运行完之后会等待用户输入任意键以退出。

Console.WriteLine("\nPress any key to quit.");

Console.ReadKey();

HelloWorld:

using System;

namespace HelloWorld

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Hello World !");

Console.WriteLine("\nPress any key to quit.");

Console.ReadKey();

}

}

}