int a = Convert.ToInt32(num.Substring(0,1)); if(a!=1) { MessageBox.Show("第一位必须是1"); return; } int second = Convert.ToInt32(num.Substring(1, 1)); if (second>8||second<3) { MessageBox.Show("第二位必须是3-8"); return; }
} else if (num.Length==12) { string s = num.Substring(4,1); if (s!="-") { MessageBox.Show("格式必须是xxxx-xxxxxxx "); return; }