Reputation: 21
Hey y'all I'm writing my first program and I've chosen C#. I'm trying to write a little dialogue at the beginning of what will be a multiple choice quiz. According to youtube videos and forums I should be able to do a WriteLine followed by a blank ReadLine and the program should continue after anything is entered. But when I provide it with input it just drops down a line and continues to wait for a prompt. Is this an issue caused by vscode? Also I am just modifying the basic hello world script. Here is some code. thanks.
using System;
namespace C_
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("In 5 seconds the teacher will begin to speak...");
Console.ReadLine();
Console.WriteLine("You will be tested for aptitude in the realm of being a worthy human.");
Console.ReadLine();
}
}
}
Upvotes: 1
Views: 1375
Reputation: 4848
This is an issue with the Visual Studio Code environment. The launch.json
contains setting that will control the way your app executes.
By default the attribute: "console" is set to the value "internalConsole". So it looks like this:
"console": "internalConsole"
In order to use Console.ReadLine();
or Console.ReadKey();
change to:
"console": "integratedTerminal"
And then switch to "Terminal" in the lower panel while debugging.
In order to 'automatically' switch to the "Terminal" panel add:
"internalConsoleOptions": "neverOpen"
Upvotes: 10