1 private int GetAgeBycode(string b_car_code) 2 { 3 string birthday = ""; 4 //處理18位的身份證號碼從號碼中獲得生日和性別代碼 5 if (b_car_code.Length == 18) 6 { 7 birthday = b_car_code.Substring(6, 4) + "-" + b_car_code.Substring(10, 2) + "-" + b_car_code.Substring(12, 2); 8 } 9 //處理15位的身份證號碼從號碼中獲得生日和性別代碼 10 if (b_car_code.Length == 15) 11 { 12 birthday = "19" + b_car_code.Substring(6, 2) + "-" + b_car_code.Substring(8, 2) + "-" + b_car_code.Substring(10, 2); 13 } 14 return birthday; 15 16 }