C# 判断字符串是否为数字

public static bool IsNumber(string s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
const string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
bool RET = rx.IsMatch(s);
return rx.IsMatch(s);
}

posted @ 2021-02-26 16:16  马玲  阅读(826)  评论(0编辑  收藏  举报