string plate="粤BN1223"; if (plate.Contains("粤BN")) { //除掉前三个字符,剩下的4个字符全为数字方为特殊车辆 bool BNum = true; char[] strSubCCode = new char[4]; if (plate.Length == 7) { plate.CopyTo(3, strSubCCode, 0, 4); foreach (char c in strSubCCode) { if (!Char.IsNumber(c)) { BNum = false; break; } } if (BNum) { Print.Log("特殊车辆:" + plate+ ",免费放行"); } } }