室内地胶价格:C# 判断一个字符串变量是否存储一串数字!

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 01:19:03
类似isNumber()函数功能。

自己写函数判断
private bool isNumeric(string str)
{
if (str == null || str.Length == 0)
return false;
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
byte[] bytestr = ascii.GetBytes(str);
foreach(byte c in bytestr)
{
if (c < 48 || c > 57)
{
return false;
}
}
return true;
}