public static bool IsIntNum(string str,bool msg)
{
System.Text.RegularExpressions.Regex reg1
= new System.Text.RegularExpressions.
Regex(@"^[-]?[1-9]{1}\d*$|^[0]{1}$");
bool ismatch=reg1.IsMatch(str);
if(!ismatch)
MessageBox.Show("您输入的数字不是整数!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return ismatch;
}
注意,这里调用了MessageBox对象,必须在引用时引用Windows.form
温馨提示:答案为网友推荐,仅供参考