C# equivalent of NaN or IsNumeric
- by johnc
This seems like a fairly simple question, and I'm surprised not to have required it before.
What is the most efficient way of testing a string input is a numeric (or conversely Not A Number).
I guess I can do a Double.Parse or a regex (see below)
public static bool IsNumeric(this string value)
{
return Regex.IsMatch(value, "^\\d+$");
}
but I was wondering if there was a implemented way to do it, such as javascript's NaN() or IsNumeric() (was that VB, I can't remember).