Identify men and women using ID card numbers

Source: Internet
Author: User
/// <Summary> /// determine men and women by ID card number /// </Summary> /// <Param name = "stridcard"> NULL: cannot be blank. Number of digits: the number of digits is incorrect. Null: program exception </param> Public static string getsexbyidcard (string stridcard) {try {string strsex = ""; // obtain the entered ID number if (string. isnullorempty (stridcard) {// ID card number cannot be blank. If it is empty, return strsex = "blank"; return strsex ;} else {// ID card number can only be 15 or 18 other illegal if (stridcard. length! = 15 & stridcard. length! = 18) {strsex = "digits"; return strsex ;}// string Birthday = ""; string sex = ""; // process the 18-digit ID card number to get the birthday and gender code from the number if (stridcard. length = 18) {// Birthday = stridcard. substring (6, 4) + "-" + stridcard. substring (10, 2) + "-" + stridcard. substring (12, 2); Sex = stridcard. substring (14, 3);} // process the 15-digit ID card number to get the birthday and gender code from the number if (stridcard. length = 15) {// Birthday = "19" + stridcard. substring (6, 2) + "-" + stridcard. substring (8, 2) + "-" + stridcard. substring (10, 2); Sex = stridcard. substring (12, 3);} // textbox_birthday.text = birthday; // If (INT. parse (sex) % 2 = 0) {strsex = "female" ;}else {strsex = "male" ;}return strsex ;}catch {return NULL ;}}

Supports 15-digit and 18-digit ID cards.

Identify men and women using ID card numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.