✅ 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
Use the debugger to see where your code goes
See if execution even gets there
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
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
You should print the entered string or debug through it.
i already printed the entered string
Console.WriteLine()
is not a debugger
Use the debugger, step through the code, see what happenshow do i use the debugger?
$debug
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.
thanks
i figured out what was the cause of this! all i needed was to change the behavior of the while loop. thanks!
$close if you have no further questions :)
Use the /close command to mark a forum thread as answered