I am learning C# and I am using VS Code, when I tried to take input from user using Console.ReadLine() it's not working.
I referred from a video which did exactly same thing and still after a couple of Google searches I couldn't figure out where I went wrong.
Console.WriteLine("Enter your name : ");
string name = Console.ReadLine();
Console.WriteLine("Hi! {0}", name);
My main method has only this 3 lines and it always gives as output something like this:
Screencast:
It never prints the last line of code
This was happening because the default console in VS Code was external terminal. If you set it integrated terminal, it allows you to take input from user.
It can be done by setting "console": "integratedTerminal" in launch.json file.
it actually works, but it happens so fast you can not see it.
try adding Console.ReadKey();
this way the program will not stop until you press a random key on your keyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With