实现效果:
知识运用:
实现代码:
private void button1_Click(object sender, EventArgs e) { if (Validate(textBox1.Text.ToString())) MessageBox.Show("验证通过"); else MessageBox.Show("输入不符合"); } //定义方法 public bool Validate(string str) { return System.Text.RegularExpressions. Regex.IsMatch(str,@"^\d{16,18}$"); }
原文:https://www.cnblogs.com/feiyucha/p/10018090.html