身份证格式验证(含15位转换到18位)C#

80酷酷网    80kuku.com

  转换

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                Console.Write("{0}:    ", i);
                for (int k = 1; k <= i; k++)
                {
                    Console.Write("{0}" + "  ", i * k);
                }
              
              
                Console.WriteLine();
            }
            string str = "620102197811196218";
            CheckCid t = new CheckCid();
            string str1 = t.CheckCidInfo(str);
            Console.Write(str1);
        }

        /// <summary>
        /// 15 to 19
        /// </summary>
        public class IDCard
        {
            // wi =2(n-1)(mod 11)
            int[] wi = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 };
            // verify digit
            int[] vi = new int[] { 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 };
            private int[] ai = new int[18];
            public IDCard()
            {
            }
            //verify
            public string Verify(string idcard)
            {
                string strCard = "";
                if (idcard.Length == 15)
                {
                    strCard = uptoeighteen(idcard);
                }
                if (idcard.Length == 18)
                {
                    strCard = idcard;
                }
                //string verify = idcard.Substring(17, 18);
                //if (verify.Equals(getVerify(idcard))) {
                //return true;
                /

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: