您当前位置:编程帮手 > 知识 > 知识 > .net逻辑代码 > 待归类 > 内容
代码库
2014-06-15 14:21:11 访问(4777) 赞(0) 踩(0)
#region 获得IP的Long值 /// /// 获得IP的Long值 /// /// /// public static ulong IpToULong(string ip) { if (ip == null || ip.Length == 0) throw new Exception("ip == null || ip.Length == 0"); ip = ip.Trim(); if (ip.Length == 0) throw new Exception("ip.Trim().Length == 0"); string[] strIpArray = ip.Split('.'); if (strIpArray == null || strIpArray.Length != 4) throw new Exception("string ip[" + ip + "] 为无效IP"); return ulong.Parse(strIpArray[0]) * 256 * 256 * 256 + ulong.Parse(strIpArray[1]) * 256 * 256 + ulong.Parse(strIpArray[2]) * 256 + ulong.Parse(strIpArray[3]) - 1; } #endregion 获得IP的Long值
上一条:
下一条: