private void buttonCheckCardID_Click(object sender, EventArgs e) { textBoxCheckCardIDArea.Text = ""; textBoxCheckCardIDGender.Text = ""; textBoxCheckCardIDAge.Text = ""; string cardID = textBoxCheckCardID.Text.Trim(); int gender = -1; DateTime brithday = default(DateTime); string area = ""; string errMsg = ""; bool result = RegexUtils.CheckCardID(cardID.ToUpper(), out gender, out brithday, out area, out errMsg); if (result) { string genderStr = gender == 1 ? "男" : "女"; int age = RegexUtils.CalculateAgeCorrect(brithday, DateTime.Now); textBoxLog.AppendText($"身份证号:{cardID}, 性别:{genderStr}, 年龄:{age}, 地区:{area}\r\n"); textBoxCheckCardIDArea.Text = area; textBoxCheckCardIDGender.Text = genderStr; textBoxCheckCardIDAge.Text = age.ToString(); } else { MessageBox.Show($"{errMsg}\r\n", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxLog.AppendText($""); } }