C#C
C#2y ago
d3adin.

✅ Console Readline accepting empty value.

Hi all,
I'm trying to set console readline to not accept empty value (""). However, I've tried a bunch of different options and I still get "System.FormatException: 'The input string '' was not in a correct format.'
"

Here is my code
do
{
    Console.WriteLine("Player 1, how far away from the city do you want to station the Manticore? ");
    manticoreDistance = Convert.ToInt32(readResult);
} while (manticoreDistance < 0 || manticoreDistance > 100);
Console.Clear();

Ideally the goal was to make a loop that displays a message stating that a number needs to be entered.
Was this page helpful?