-1

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

2 Answers2

1

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.

0

We can found answer in OmniSharp Visual Code docs: https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window

enter image description here

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

Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10