C
C#13mo 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
Angius13mo ago
Use the debugger to see where your code goes See if execution even gets there
ACiDCA7
ACiDCA713mo 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
MeiOP13mo 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
SpicyCatGames13mo ago
You should print the entered string or debug through it.
Mei
MeiOP13mo ago
i already printed the entered string
No description
Angius
Angius13mo ago
Console.WriteLine() is not a debugger Use the debugger, step through the code, see what happens
Mei
MeiOP13mo ago
how do i use the debugger?
Angius
Angius13mo ago
$debug
MODiX
MODiX13mo 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
MeiOP13mo ago
thanks
Mei
MeiOP13mo 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
sibber13mo ago
$close if you have no further questions :)
MODiX
MODiX13mo ago
Use the /close command to mark a forum thread as answered

Did you find this page helpful?