[Originally Posted By]: http://stackoverflow.com/questions/894263/how-do-i-identify-if-a-string-is-a-number
If I have these strings:
Is there a command, like IsNumeric or something else, that can identify if a string is a valid number?
int n; bool isNumeric = int.TryParse("123", out n);
This will return true if
input is all numbers. Don’t know if it’s any better than
TryParse, but it will work.
If you just want to know if it has one or more numbers mixed in with characters, leave off the
Edit: Actually I think it is better than TryParse because a very long string could potentially overflow TryParse.