Code from http://topic.csdn.net/u/20101231/09/039bdd22-3f0a-4bbb-908e-d887b4d7bbfe.html?
19933
Public static class util {// <summary> // check whether the ID card information is valid /// 2010-10-13 jorln /// </Summary> /// <Param name = "num"> ID card number </param> /// <Param name = "sex"> gender </param> /// <returns> </returns> Public static bool checkidentity (string num, string sex) {bool isiden = false; If (convert. toint32 (Num. substring (6, 4)> 1850 & convert. toint32 (Num. substring (6, 4) <2010 & convert. toint32 (Num. substring (10, 2) <= 12 & convert. toint32 (Num. substring (12, 2) <= 31) {If (Num. substring (10, 2) = "02" & convert. toint32 (Num. substring (10, 2)> 29) return isiden; If (convert. toint32 (Num. substring (16, 1) % 2 = 0 & sex = "") | (convert. toint32 (Num. substring (16, 1) % 2! = 0 & sex = "male") {int COUNT = 0; int [] iden = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2,}; For (INT I = 0; I <iden. length; I ++) {count + = convert. toint32 (Num. substring (I, 1) * iden [I];} int cc = count % 11; char num18 = Cc = 0? '1': (Cc = 1? '2': (Cc = 2? 'X': (Cc = 3? '9': (Cc = 4? '8': (Cc = 5? '7': (Cc = 6? '6': (Cc = 7? '5': (Cc = 8? '4': (Cc = 9? '3': '2'); isiden = num. substring (17, 1). toupper () = num18.tostring ()? True: false ;}} return isiden ;}}