C
C#2y ago
Fallzy

❔ 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
Pobiega
Pobiega2y ago
that should run fine. how are you running it? and what is the error its showing?
Fallzy
FallzyOP2y ago
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
Pobiega
Pobiega2y ago
debug console vs "actual" console? how are you starting it?
Fallzy
FallzyOP2y ago
before I did some print statements and it opened in its own window
Pobiega
Pobiega2y ago
what are you using to code in?
Fallzy
FallzyOP2y ago
Vs Code
Pobiega
Pobiega2y ago
okay
ero
ero2y ago
does this typing include enter presses too?
Fallzy
FallzyOP2y ago
yes I can hop in a call if someonee wants?
Buddy
Buddy2y ago
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
Moods
Moods2y ago
im not sure what they did but it worked perfectly in vscode
TheRanger
TheRanger2y ago
sounds like they needed to type dotnet run in the terminal instead
Angius
Angius2y ago
Well, as long as you use dotnet run, VSC has nothing to do with it
Moods
Moods2y ago
literally copypasted it
Angius
Angius2y ago
As long as you don't use csc it should be fine
TheRanger
TheRanger2y ago
their vscode is probably configured to run, urs probably isnt
Fallzy
FallzyOP2y ago
okay Ill try that thanks. I was just using vsc cause I was watching a tutorial
Angius
Angius2y ago
$vscode
MODiX
MODiX2y ago
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
Angius
Angius2y ago
Oh, someone updated it from O# to DevKit, nice
Fallzy
FallzyOP2y ago
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"?
TheRanger
TheRanger2y ago
VSCode isn't beginner friendly, ur gonna have to config your launch settings
Fallzy
FallzyOP2y ago
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
TheRanger
TheRanger2y ago
did you input? VSCode has a terminal u know
Fallzy
FallzyOP2y ago
yeah I did Yeah I know I just wanted to try with the external
TheRanger
TheRanger2y ago
the program probably finished executing, thus it got closed
Fallzy
FallzyOP2y ago
The internal works ohh yes okay I need an input again It works! Thanks for the help everyone
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server