Saturday, 7 September 2013

Return user to point of data entry C# Console application

Return user to point of data entry C# Console application

In the example below, assuming the user enters a negative number, how can
I bring the cursor back to the same place where the user entered an
invalid number so that the program can continue on?
Console.Write("Enter a number for the factorial: ");
int k = Convert.ToInt32(Console.ReadLine());
if (k < 0)
{
Console.WriteLine("Please enter a number that is greater than or equal
to zero");
}

No comments:

Post a Comment