string s="^[0-9]*$";//正则表达式 Regex reg=new Regex(s); if(!reg.IsMatch(this.textbox1.text)) { MessageBox.Show("请输入数字"); }