S
sck10
Hello,
I am trying to test for IsNumeric using C# with the following:
public bool IsNumeric(object TestValue)
{
try
{
int i = Convert.ToInt32(TestValue.ToString());
return true;
}
catch (FormatException)
{
return false;
}
}
If I use ToInt32, I get the error: "System.OverflowException: Value was
either too large or too small for an Int32." For a value of 9999999999
If I try: int i = Convert.ToInt64(TestValue.ToString());
Cannot implicitly convert type 'long' to 'int'. An explicit conversion
exists (are you missing a cast?)
Any assistance on why Convert.ToInt64 is failing would be appreciated.
Thanks, sck10
I am trying to test for IsNumeric using C# with the following:
public bool IsNumeric(object TestValue)
{
try
{
int i = Convert.ToInt32(TestValue.ToString());
return true;
}
catch (FormatException)
{
return false;
}
}
If I use ToInt32, I get the error: "System.OverflowException: Value was
either too large or too small for an Int32." For a value of 9999999999
If I try: int i = Convert.ToInt64(TestValue.ToString());
Cannot implicitly convert type 'long' to 'int'. An explicit conversion
exists (are you missing a cast?)
Any assistance on why Convert.ToInt64 is failing would be appreciated.
Thanks, sck10