Can someone please help me to know why below piece of code giving me Overflow exception even if I use long and double datatype of variable numValue: tring[] inputValues = new string[] { "3", "9999999999", "0", "2" };
foreach (string inputValue in inputValues)
{
long numValue = 0;
try
{
numValue = int.Parse(inputValue);
}
catch (FormatException)
{
Console.WriteLine("Invalid readResult. Please enter a valid number.");
}
catch (OverflowException)
{
Console.WriteLine("The number you entered is too large or too small.");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
I tried changing the data type of numValue variable.