'How to stop command window from closing after hitting enter

I am a complete beginner so I really have no idea what I'm doing.


namespace first_program
{
  class first_program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World!");
      Console.ReadLine();
      Console.WriteLine("Hello World!");
    }
  }
} 

I am using VS Code and whenever I run this code the command prompt opens up, but whenever I press enter after typing into it the window closes.

Is there something wrong with my code? Or is it a bug with VS Studio?

I have copied all of this code from a Youtube tutorial by Brackeys titled "How to Program in C#"

It also my be important for me to note that a message saying "The program '[10260] first program.dll' has exited with code 0 (0x0)." pops up in the debug terminal.



Solution 1:[1]

Place Console.ReadKey() after the writeLine stuff, and it will wait for a keyboard interaction to close.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ombolics