当前位置:首页 > C#教程 > C#高级

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

/// <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);
}

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐