是否是数字判断

/// <summary>
/// 判断字符串是否是数字
/// </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);
}

posted @ 2019-03-23 19:41  厦门哈韩  阅读(118)  评论(0编辑  收藏  举报