实现效果:
知识运用:
实现代码:
private void button1_Click(object sender, EventArgs e) { if (IsValidate(textBox1.Text.ToString())) label1.Text = "输入正确"; else label1.Text = "请输入数字"; } public bool IsValidate(string str_number) { return System.Text.RegularExpressions. Regex.IsMatch(str_number,@"^[0-9]*$"); }