c# 自动生成 身份证 中文名

来源:互联网 发布:淘宝卖家问大家功能 编辑:程序博客网 时间:2024/06/05 15:31
 身份证

 

  1. private void GenPinCode()
  2.   {
  3. System.Random rnd;
  4.   string[] _crabodistrict=new string[]{"350201","350202","350203","350204","350205","350206","350211","350205","350213"};
  5.    rnd = new Random(System.DateTime.Now.Millisecond);
  6.    
  7.    //PIN = District + Year(50-92) + Month(01-12) + Date(01-30) + Seq(001-600)
  8.    string _pinCode=string.Format("{0}19{1}{2:00}{3:00}{4:000}",_crabodistrict[rnd.Next(0,8)],rnd.Next(50,92),rnd.Next(1,12),rnd.Next(1,30),rnd.Next(1,600));
  9.    #region Verify
  10.    char[] _chrPinCode = _pinCode.ToCharArray();
  11.    //校验码字符值
  12.    char[] _chrVerify=new char[]{'1''0''X''9''8''7''6''5''4''3''2'};
  13.    //i----表示号码字符从由至左包括校验码在内的位置序号;
  14.    //ai----表示第i位置上的号码字符值;
  15.    //Wi----示第i位置上的加权因子,其数值依据公式intWeight=2(n-1)(mod 11)计算得出。
  16.    int[] _intWeight=new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1};
  17.    int _craboWeight=0;
  18.    for(int i=0;i<17;i++)//从1 到 17 位,18为要生成的验证码
  19.    {
  20.     _craboWeight=_craboWeight+Convert.ToUInt16(_chrPinCode[i].ToString())*_intWeight[i];
  21.    }
  22.    _craboWeight=_craboWeight%11;
  23.    _pinCode+=_chrVerify[_craboWeight];
  24.    #endregion
  25.    this.txtPIN.Text=_pinCode;
  26.   }

中文名字

  1. http://blog.csdn.net/crabo/
  2. #region My Init
  3.   System.Random rnd;
  4.   string[] _crabofirstName=new string[]{  "白","毕","卞","蔡","曹","岑","常","车","陈","成" ,"程","池","邓","丁","范","方","樊","费","冯","符"
  5.            ,"傅","甘","高","葛","龚","古","关","郭","韩","何" ,"贺","洪","侯","胡","华","黄","霍","姬","简","江"
  6.            ,"姜","蒋","金","康","柯","孔","赖","郎","乐","雷" ,"黎","李","连","廉","梁","廖","林","凌","刘","柳"
  7.            ,"龙","卢","鲁","陆","路","吕","罗","骆","马","梅" ,"孟","莫","母","穆","倪","宁","欧","区","潘","彭"
  8.            ,"蒲","皮","齐","戚","钱","强","秦","丘","邱","饶" ,"任","沈","盛","施","石","时","史","司徒","苏","孙"
  9.            ,"谭","汤","唐","陶","田","童","涂","王","危","韦" ,"卫","魏","温","文","翁","巫","邬","吴","伍","武"
  10.            ,"席","夏","萧","谢","辛","邢","徐","许","薛","严" ,"颜","杨","叶","易","殷","尤","于","余","俞","虞"
  11.            ,"元","袁","岳","云","曾","詹","张","章","赵","郑" ,"钟","周","邹","朱","褚","庄","卓" };
  12.   string _lastName="是一种优秀的数据打包和数据交换的形式在当今大行于天下如果没有听说过它的大名那可真是孤陋寡闻了用描述数据的优势显而易见它具有结构简单便于人和机器阅读的双重功效并弥补了关系型数据对客观世界中真实数据描述能力的不足组织根据技术领域的需要制定出了的格式规范并相应的建立了描述模型简称各种流行的"
  13.     #endregion
  14. #region GenName
  15.   private void GenName()
  16.   {
  17.    rnd = new Random(System.DateTime.Now.Millisecond);
  18.    this.txtName.Text=string.Format("{0}{1}{2}",_firstName[rnd.Next(_crabofirstName.Length-1)],_lastName.Substring(rnd.Next(0,_lastName.Length-1),1),_lastName.Substring(rnd.Next(0,_lastName.Length-1),1));
  19.   }
  20.   #endregion