15位的身份证号转为18位
发布日期:2021-06-30 19:01:15
浏览次数:3
分类:技术文章
本文共 908 字,大约阅读时间需要 3 分钟。
C# 版 function ID15T18(strTemp) { var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); var nTemp = 0, i; if(strTemp.length==15) { strTemp = strTemp.substr(0,6) + '19' + strTemp.substr(6,strTemp.length-6); for(i = 0; i < strTemp.length; i ++) { nTemp += strTemp.substr(i, 1) * arrInt[i]; }strTemp += arrCh[nTemp % 11]; } return strTemp;} VB 版 private string Convert15To18(string strTemp){ int[] arrInt = new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};string arrCh="10X98765432";int nTemp = 0;if(strTemp.Length==15){ strTemp = strTemp.Substring(0,6) + "19" + strTemp.Substring(6,strTemp.Length-6);for(int i = 0; i < strTemp.Length; i++){ nTemp += int.Parse(strTemp.Substring(i, 1).ToString()) * arrInt[i];}strTemp += arrCh[nTemp % 11]; }char dd=arrCh[nTemp % 11]; return strTemp;} | |
转载地址:https://linuxstyle.blog.csdn.net/article/details/149834 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月27日 00时52分08秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【工具和环境】Linux下安装pycharm
2019-04-30
【Accumulation】The definition of SISR
2019-04-30
【工具与环境】Windows下安装Sublime Text 3
2019-04-30
【工具与环境】Excel中批量插入行
2019-04-30
【个人实验注意事项】
2019-04-30
【学习笔记】对vanilla的一些个人理解
2019-04-30
【解决错误】The size of tensor a (8) must match the size of tensor b (64) at non-singleton dimension 1
2019-04-30
word文档中实现目录索引中标题加粗,前导符和页码不加粗
2019-04-30
“学硕” VS “专硕”
2019-04-30
【NLP学习笔记】知识图谱阅读笔记及其心得
2019-04-30
【工具使用】新版CSDN-markdown编辑器使用指南
2019-04-30
《知识图谱》阅读笔记(六)
2019-04-30
【NLP学习笔记】中文分词(Word Segmentation,WS)
2019-04-30
【NLP学习笔记】词性标注(Part-of-speech Tagging, POS)
2019-04-30