最佳答案
What is the most efficient way of testing an input string whether it contains a numeric value (or conversely Not A Number)? I guess I can use Double.Parse
or a regex (see below) but I was wondering if there is some built in way to do this, such as javascript's NaN()
or IsNumeric()
(was that VB, I can't remember?).
public static bool IsNumeric(this string value)
{
return Regex.IsMatch(value, "^\\d+$");
}