Maha

Maha

  • NA
  • 0
  • 326k

Exception type for non-integer

Jun 27 2013 9:21 AM
This program wants you to enter a stock number and quantity. I wish to know the exception type for non-integer to complete this program.

For example: DivideByZeroException is an exception type if a number is divided by zero.

using System;
namespace _2
{
class Program
{
static void Main(string[] args)
{

re_enter:
while (true)
{
try
{
Console.Write("Enter a stock number: ");
int stockNo = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter a stock quantity: ");
int quantity = Convert.ToInt32(Console.ReadLine());
}
catch (Exception error)
{
Console.WriteLine(error.Message);
if (error is non_integer)
{
stockNo = 1;
goto re_enter;
}
}

}

Console.ReadKey();
}
}
}


Answers (2)