IsDecimal or IsNumber

S

sloan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top