网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > C#应用
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.StringWriter实现的一个功能.
.在C#中利用DirectX实现声音播放.
.c#中获取存储过程方法.
.C#反编译微软MSDN2003的帮助文档.
.c# 实现Word联接Excel的MailMerg.
.利用c#制作简单的留言板(3).
.c#获取真实IP和代理IP.
.如何获取当前操作系统的软件版本.
.用API得到局域网中可用SqlServer.
.再现C#导出Excel源码.
.用C#访问ACCESS数据库问题.
.用 C# 开发 SQL Server 2005 的自.
.Web Service的几个很重要的概念 .
.c# arraylist functions .
.C#重用UDP端口号.
.C#实现的根据年月日计算星期几的.
.如何用C#将数据库中的记录制成XML.
.在C#中应用哈希表(Hashtable) .
.用C#对DBF数据库的操作.
.用C#下的Raw Socket编程实现网络.

用C#实现由15位身份证号升级到18位的算法

发表日期:2006-11-14


1using System;
 2using System.Collections;
 3
 4public class MyClass
 5{
 6    public static void Main()
 7    {
 8        Console.WriteLine(per15To18("429005811009091"));
 9        RL();
10    }
11   
12    public static string per15To18(string perIDSrc)
13  {
14   int iS = 0;
15
16   //加权因子常数
17   int[] iW=new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
18   //校验码常数
19   string LastCode="10X98765432";
20   //新身份证号
21   string perIDNew;
22
23   perIDNew=perIDSrc.Substring(0,6);
24   //填在第6位及第7位上填上‘1’,‘9’两个数字
25   perIDNew += "19";
26
27   perIDNew += perIDSrc.Substring(6,9);
28
29   //进行加权求和
30   for( int i=0; i<17; i++)
31   {
32    iS += int.Parse(perIDNew.Substring(i,1)) * iW[i];
33   }
34    
35   //取模运算,得到模值
36   int iY = iS%11;
37   //从LastCode中取得以模为索引号的值,加到身份证的最后一位,即为新身份证号。
38   perIDNew += LastCode.Substring(iY,1);
39
40   return perIDNew;
41  }
42
43
44
45   
46    Helper methods#region Helper methods
47
48    private static void WL(object text, params object[] args)
49    {
50        Console.WriteLine(text.ToString(), args);   
51    }
52   
53    private static void RL()
54    {
55        Console.ReadLine();   
56    }
57   
58    private static void Break()
59    {
60        System.Diagnostics.Debugger.Break();
61    }
62
63    #endregion
64}
http://www.cnblogs.com/goody9807/archive/2006/11/13/559378.html
上一篇:C#进制转换 的记录 人气:6361
下一篇:关于C#中的DateTime类型的细节问题 人气:9979
浏览全部c#的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐