if(reg1.IsMatch(str))
{
//数字
}
else
{
//非数字
}
///
/// 判断是否是数字
///
/// 字符串
///
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;
}
//判断是否为数字
public static bool StrIsInt(string Str)
{
try
{
Int32.Parse(Str);
return true;
}
catch
{
bool flag = false;
return flag;
}
}