public static bool IsNumber(string input)
{
string pattern = @"^[-]?(\d+\.?\d*|\.\d+)$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input.Replace(",", ""));
}
c# 判断是否数值
最新推荐文章于 2024-02-24 10:32:30 发布
public static bool IsNumber(string input)
{
string pattern = @"^[-]?(\d+\.?\d*|\.\d+)$";
Regex regex = new Regex(pattern);
return regex.IsMatch(input.Replace(",", ""));
}