❔ Code not running.
Hey guys. I've just started learning C# today and I made the following code
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Whats your name?");
string userName = Console.ReadLine();
Console.WriteLine("Hello " + userName + " Welcome");
}
}
I think everything should be fine but its not running at all, it shows an error around Console.ReadLine() and Im not really sure how to fix it.
28 Replies
that should run fine. how are you running it?
and what is the error its showing?
Doent show an error. It just runs in the debug console instead of the actual console and doesnt do anything after the Writeline it just lets me type indefinately
debug console vs "actual" console?
how are you starting it?
before I did some print statements and it opened in its own window
what are you using to code in?
Vs Code
okay
does this typing include enter presses too?
yes
I can hop in a call if someonee wants?
I highly recommend to not use VSCode and use Visual Studio Community If you are a beginner
VSCode and it's extensions for C# are really glitchy
It can show random "ghost" errors
im not sure what they did but it worked perfectly in vscode
sounds like they needed to type
dotnet run
in the terminal insteadWell, as long as you use
dotnet run
, VSC has nothing to do with itliterally copypasted it
As long as you don't use
csc
it should be finetheir vscode is probably configured to run, urs probably isnt
okay Ill try that thanks. I was just using vsc cause I was watching a tutorial
$vscode
Follow the instructions here on getting started with DevKit for C# in VSCode: https://code.visualstudio.com/docs/csharp/get-started
Get started with C# and .NET in Visual Studio Code
Getting Started with C# and .NET Development in Visual Studio Code
Oh, someone updated it from O# to DevKit, nice
I did that video lol
Okay when I do dotnet run it seems to work
That makes me think that it could be something wrong with launch
Is it supposed to be "InternalConsole"?
VSCode isn't beginner friendly, ur gonna have to config your launch settings
I know but I want to try stay on it for the tutorials at least
Okay so Ive got it going into an external terminal but for some reason it stops running after the read line
did you input?
VSCode has a terminal u know
yeah I did
Yeah I know I just wanted to try with the external
the program probably finished executing, thus it got closed
The internal works
ohh yes okay I need an input again
It works!
Thanks for the help everyone
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.