Created
August 18, 2014 13:35
-
-
Save jltrem/166aca602cb924fe653d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsNumeric(this string str) | |
{ | |
decimal dec; | |
bool numeric = decimal.TryParse(str, out dec); | |
if (!numeric) | |
{ | |
// this will handle scientific notation (e.g., "314e-2") | |
numeric = decimal.TryParse(str, System.Globalization.NumberStyles.Float, null, out dec); | |
} | |
return numeric; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment