By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,169 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,169 IT Pros & Developers. It's quick & easy.

IsDecimal or IsNumber

P: n/a
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
Jan 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"sloan" <sl***@ipass.netwrote in message
news:Oh*************@TK2MSFTNGP02.phx.gbl...
Does anyone know of a way to check a string... being a Number or
Decimal...
http://msdn2.microsoft.com/en-us/lib....tryparse.aspx
Jan 26 '07 #2

P: n/a
Duhhh. (to myself).

Thanks Mark..........its been a long week.
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uW*************@TK2MSFTNGP02.phx.gbl...
"sloan" <sl***@ipass.netwrote in message
news:Oh*************@TK2MSFTNGP02.phx.gbl...
Does anyone know of a way to check a string... being a Number or
Decimal...

http://msdn2.microsoft.com/en-us/lib....tryparse.aspx


Jan 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.