C#判断字符串是否是数字(实例)
时间:2022-01-10 15:17:46|栏目:.NET代码|点击: 次
话不多说,请看代码
/// <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);
}
上一篇:.net中前台javascript与后台c#函数相互调用问题
栏 目:.NET代码
本文标题:C#判断字符串是否是数字(实例)
本文地址:http://www.codeinn.net/misctech/189701.html






