使用正则表达是验证邮政编码
发布时间:2020-12-14 06:13:03 所属栏目:百科 来源:网络整理
导读:实现效果: 知识运用: ? 实现代码: private void button1_Click( object sender,EventArgs e) { // 三目运算判断 object bl = IsValidate(textBox1.Text.ToString()) == true ? MessageBox.Show( " 验证通过 " ) : MessageBox.Show( " 验证失败 " ); } //
实现效果: 知识运用: ? 实现代码: private void button1_Click(object sender,EventArgs e) { //三目运算判断 object bl = IsValidate(textBox1.Text.ToString()) == true ? MessageBox.Show("验证通过") : MessageBox.Show("验证失败"); } //验证方法 public bool IsValidate(string str_code) { return System.Text.RegularExpressions.Regex. IsMatch(str_code,@"^d{6}$"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |