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