程序运行结束打印完HelloWorld之后因为没有其他任务了,所以就退出了,又因为打印速度很快,所以我们会看到一个一闪而过的黑窗。 加入以下代码,程序运行完之后会等待用户输入任意键以退出。
Console.WriteLine("\nPress any key to quit.");
Console.ReadKey();
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World !");
Console.WriteLine("\nPress any key to quit.");
Console.ReadKey();
}
}
}
C# 调试HelloWorld 闪退 C# 所有作业和实验报告