//添加正则表达式类Regex
using System.Text.RegularExpressions;
public static bool digitjdg(string x)
{
const string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
bool IsDigit = rx.IsMatch(x);
return IsDigit;//是数字返回true,不是返回false
}
C#判断字符是否为数字
最新推荐文章于 2025-03-27 16:30:45 发布