c# textbox中要进行车牌号验证输入

1:先定义一个数组来保存车牌号的第一位:private List<string> str1 = new List<string>() { "京", "津", "冀", "晋", "蒙", "辽", "吉",

"黑", "沪", "苏", "浙", "皖", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "渝", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "学" };车牌号的第一位只能从中选择一个。

2:车牌号的第二位判断必须是大写字母: 其中strNow是textbox中的值, if (strNow.Length == 2 && !(Convert.ToInt32(strNow[1]) > Convert.ToInt32('A') - 1 && Convert.ToInt32(strNow[1]) < Convert.ToInt32('Z') + 1))

3:车牌号中剩下的后五位只能是大写字母或数字: if (strNow.Length > 2 && !(

(Convert.ToInt32(strNow[strNow.Length - 1]) > Convert.ToInt32('A') - 1 && Convert.ToInt32(strNow[strNow.Length - 1]) < Convert.ToInt32('Z') + 1) ||

(Convert.ToInt32(strNow[strNow.Length - 1]) > Convert.ToInt32('0') - 1 && Convert.ToInt32(strNow[strNow.Length - 1]) < Convert.ToInt32('9') + 1)) )

4:判断textbox中的值长度不能超过8位: if (strNow.Length > 8)