Home > other >  When running a c# code in vs code, i doesn't open the console
When running a c# code in vs code, i doesn't open the console

Time:01-28

The code is:

Console.WriteLine("Hello, World!");Console.ReadKey();

And it gives me this error:

Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read

CodePudding user response:

When creating a new Project in Visual Studio, make sure to select a Console Application Type as your Project Template.

It is possible to change the Project Type after creating a Project through the Project Properties, but since it looks like you are starting from scratch, you might want to restart with a new project template.

CodePudding user response:

We can found answer in OmniSharp Visual Code docs: enter image description here

You can also refer to this page: ReadKey not working in .net core

  •  Tags:  
  • Related