C Determines whether a string is a number (instance)
- 2021-11-24 02:40:53
- OfStack
Not much to say, please look at the code
/// <summary>
/// Determine whether the string is a number
/// </summary>
public static bool IsNumber(string s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
const string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
return rx.IsMatch(s);
}