Visual Studio terminates my console application too fast

前端 未结 5 692
温柔的废话
温柔的废话 2020-12-21 19:12

When I execute my program in Visual Studio (just a simple hello world app) it terminates and closes the console window immediately, rather than waiting for me to close it ma

5条回答
  •  感动是毒
    2020-12-21 19:56

    While testing Console.ReadKey() is nice to have. Here's an example:

    namespace Foo
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.Write("The Console will close when it reads a key-input. "+
                              "Press a key to close");
                Console.ReadKey();
            }
        }
    }
    

提交回复
热议问题