C
C#12mo ago
Mei

✅ Can't use "Console.ReadLine();"

Hey there! I've been trying to write a simple Fibonacci sequence in C#. Currently, I'm trying to ask the user how many numbers would they want. When I use Console.ReadLine();, the program doesn't prompt the user (this doesn't work with strings either). How can I fix this?
13 Replies
Angius
Angius12mo ago
Use the debugger to see where your code goes See if execution even gets there
ACiDCA7
ACiDCA712mo ago
are you even entering something into console or just pressing enter? if you didnt enter a number it cannot be converted to an int therfore the exception use tryparse to check if it was successfully parsed and if not prompt the user to try again
Mei
MeiOP12mo ago
the only thing i entered in the console was the enter at the beginning (it can actually be any key), nothing after that. the program just straight up skips it
SpicyCatGames
SpicyCatGames12mo ago
You should print the entered string or debug through it.
Mei
MeiOP12mo ago
i already printed the entered string
No description
Angius
Angius12mo ago
Console.WriteLine() is not a debugger Use the debugger, step through the code, see what happens
Mei
MeiOP12mo ago
how do i use the debugger?
Angius
Angius12mo ago
$debug
MODiX
MODiX12mo ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Mei
MeiOP12mo ago
thanks
Mei
MeiOP12mo ago
i figured out what was the cause of this! all i needed was to change the behavior of the while loop. thanks!
No description
sibber
sibber12mo ago
$close if you have no further questions :)
MODiX
MODiX12mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server