Method for verifying 18-bit ID number (GB11643-1999 compliant)
/// <summary> ///18-digit ID number verification/// </summary> Private Static BOOLCheckIDCard18 (stringIdNumber) { Longn =0; if(Long. TryParse (Idnumber.remove ( -), outN) = =false|| N < Math.pow (Ten, -) ||Long. TryParse (Idnumber.replace ('x','0'). Replace ('X','0'), outN) = =false) { return false;//Digital Verification } stringAddress ="11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91"; if(Address. IndexOf (Idnumber.remove (2)) == -1) { return false;//Province Verification } stringBirth = idnumber.substring (6,8). Insert (6,"-"). Insert (4,"-"); DateTime Time=NewDateTime (); if(Datetime.tryparse (Birth, outtime) = =false) { return false;//Birthday Verification } string[] Arrvarifycode = ("1,0,x,9,8,7,6,5,4,3,2"). Split (','); string[] Wi = ("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2"). Split (','); Char[] Ai = Idnumber.remove ( -). ToCharArray (); intsum =0; for(inti =0; I < -; i++) {sum+=int. Parse (Wi[i]) *int. Parse (Ai[i]. ToString ()); } inty =-1; Math.divrem (SUM, One, outy); if(Arrvarifycode[y]! = idnumber.substring ( -,1). ToLower ()) {return false;//Check Code Verification } return true;//complies with gb11643-1999 standards}
Method of verifying China's national identification number (in accordance with gb11643-1999 standard) (unknown source)