C#关于验证身份证号码的实例分析(正确性)


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

private static bool CheckIDCard15(string Id)

    {

      long n = 0;

      if (long.TryParse(Id, out n) == false || n < Math.Pow(10, 14))

      {

        return false;

      }

      string address = "11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91";

      if (address.IndexOf(Id.Remove(2)) == -1)

      {

        return false;

      }

      string birth = Id.Substring(6, 6).Insert(4, "-").Insert(2, "-");

      DateTime time = new DateTime();

      if (DateTime.TryParse(birth, out time) == false)

      {

        return false;

      }

      return true;//正确

    }

总结

以上就是C#关于验证身份证号码的实例分析(正确性)的详细内容!

返回前面的内容

相关阅读 >>

c#单例模式的实现以及性能对比的实例

c#中enum与string的相互转换的示例

c# 定时器timer的实例介绍

c#中使用反射以及特性简化的实例代码

.net中core使用socket与树莓派进行通信的实例分析(图文)

.net core和.net区别

c#如何使用正则表达式来验证中文字符的案例

.net core中如何使用ref和span<t>提高程序性能的实现代码

使用 vscode 编写 .net core 项目的实例教程

.net winform实现在listview中添加progressbar的方法

更多相关阅读请进入《csharp》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...