Hello Friends;
I am making this basic programm in C# using concole application. My programm Prompth the user to enter a number (integer) within the range 0 - 100. up this point the programm is working fine.
but when the user enters some non numeric value the i start getting system error. is there possibly a way, syntex that can actually tell that user that Only Numerals ar allowed no other value can be added.
I have Tried System.Windows.Forms and it is not working...may be bacause im working on a console application.
So how can i display an error message on the console screen that only numeric value should be entered.
here is a lice of code...that prompts the user...
could any one please help me with this ?
Thanks
§ Rented Lips §
----------------
Begning To Learn
----------------
I am making this basic programm in C# using concole application. My programm Prompth the user to enter a number (integer) within the range 0 - 100. up this point the programm is working fine.
but when the user enters some non numeric value the i start getting system error. is there possibly a way, syntex that can actually tell that user that Only Numerals ar allowed no other value can be added.
I have Tried System.Windows.Forms and it is not working...may be bacause im working on a console application.
So how can i display an error message on the console screen that only numeric value should be entered.
here is a lice of code...that prompts the user...
Code:
do // start of do while loop
{
// start of if statement
if (Number < MinRange || Number > MaxRange)
{
Console.Write("\n Error - Number must be between " + MinRange + " - " + (MaxRange - 1));
}
// tell teh user how many tries left
Console.Write("\n Tries Left " + i);
// prompt the user to enter the number and try their luck
Console.Write("\n Enter your choice --> ");
// convers the value to integer and then save it to Number variable
Number = Convert.ToInt32(Console.ReadLine());
} while (Number < MinRange || Number > MaxRange);// end while loop
could any one please help me with this ?
Thanks
§ Rented Lips §
----------------
Begning To Learn
----------------