Hi,
No, you are not missing something. Shameful isn't it? You would expect this kind of simple operation to be included somewhere in such a rich framework...
You have both of the common ways to solve this problem. Just for completeness, the regular expression approach (my personal preference) can be done using the following:
- private static Regex _isNumber = new Regex(@"^\d+$");
-
public static bool IsNumeric(string inputData) {
-
Match m = _isNumber.Match(inputData);
-
return m.Success;
-
}
You could also make incremental char comparisons within a for loop testing if each char of the string is a number.
Regards.