IsDecimal or IsNumber

IsDecimal or IsNumber

Post by sloa » Sun, 28 Jan 2007 05:49:50


Does anyone know of a way to check a string... being a Number or Decimal...

~~~without exception handling?

(Exceptional Handling is slow ... and it shows on this one)


Here is the gist...but with crappy ExceptionHandling code.:::::::


private static bool IsDecimal(string theValue)
{
bool returnVal = false;
try
{
Convert.ToDouble(theValue , CultureInfo.CurrentCulture );
returnVal = true;
}
catch (FormatException fe)
{
returnVal = false;
}
catch (OverflowException ofe)
{
returnVal = false;
}
finally
{
}

return returnVal;

} //IsDecimal
 
 
 

IsDecimal or IsNumber

Post by Mark Ra » Sun, 28 Jan 2007 05:59:28

 
 
 

IsDecimal or IsNumber

Post by sloa » Sun, 28 Jan 2007 06:27:34

Duhhh. (to myself).

Thanks Mark..........its been a long week.