软件编程
位置:首页>> 软件编程>> C#编程>> C#判断字符串是否是数字(实例)

C#判断字符串是否是数字(实例)

作者:欣宇  发布时间:2023-07-30 02:41:09 

标签: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);
}

来源:http://www.cnblogs.com/zhang625161495/p/6216992.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com