惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Latest
Security Latest
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
J
Java Code Geeks
P
Privacy International News Feed
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
博客园 - 聂微东
Project Zero
Project Zero
美团技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Scott Helme
Scott Helme
I
Intezer
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hacker News: Front Page
S
Security @ Cisco Blogs
博客园 - 司徒正美
O
OpenAI News
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
酷 壳 – CoolShell
酷 壳 – CoolShell
SecWiki News
SecWiki News
月光博客
月光博客
S
Security Affairs
The GitHub Blog
The GitHub Blog
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
V
V2EX
S
Securelist
F
Fortinet All Blogs
W
WeLiveSecurity
D
Docker
博客园 - 三生石上(FineUI控件)
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Engineering at Meta
Engineering at Meta

博客园 - 北极熊,我来了!

C#获取类以及类下的方法(用于Asp.Net MVC) 使用JavaScript判断用户是否为手机设备 手机端页面自适应解决方案 Asp 邮件发送代码 js 日期字符串转换成日期类型,判断星期几 浅析a标签的4个伪类 C#读取Rss功能函数 《中文防止乱码的万能解决方案》 《小偷程序:自动获取百度天气预报》 Asp.NET使用HTML控件上传文件 《JS两级联动菜单学习全接触》 活动目录ADSI实现添加系统帐号问题!!! ADSI管理Windows2003系统帐号 中国频道空间使用Jmail发送邮件 《单域名下整合动网、动易、OBlog程序》 JS读取XML数据 Asp.NET读取Excel数据 [XML系列]Flash读取XML数据 《省市联动功能菜单的实现》
《IP地址和数字之间转化的算法》
北极熊,我来了! · 2007-05-12 · via 博客园 - 北极熊,我来了!

public static uint IPToInt(string ipAddress)
    
{
        
string disjunctiveStr = ".,: ";
        
char[] delimiter = disjunctiveStr.ToCharArray();
        
string[] startIP = null;
        
for (int i = 1; i <= 5; i++)
        
{
            startIP 
= ipAddress.Split(delimiter, i);
        }

        
string a1 = startIP[0].ToString();
        
string a2 = startIP[1].ToString();
        
string a3 = startIP[2].ToString();
        
string a4 = startIP[3].ToString();
        
uint U1 = uint.Parse(a1);
        
uint U2 = uint.Parse(a2);
        
uint U3 = uint.Parse(a3);
        
uint U4 = uint.Parse(a4);

        
uint U = U1 << 24;
        U 
+= U2 << 16;
        U 
+= U3 << 8;
        U 
+= U4;
        
return U;
    }


    
public static string IntToIP(uint ipAddress)
    
{
        
long ui1 = ipAddress & 0xFF000000;
        ui1 
= ui1 >> 24;
        
long ui2 = ipAddress & 0x00FF0000;
        ui2 
= ui2 >> 16;
        
long ui3 = ipAddress & 0x0000FF00;
        ui3 
= ui3 >> 8;
        
long ui4 = ipAddress & 0x000000FF;
        
string IPstr = "";
        IPstr 
= System.Convert.ToString(ui1) + "." + System.Convert.ToString(ui2) + "." + System.Convert.ToString(ui3) + "." + System.Convert.ToString(ui4);
        
return IPstr;
    }

最近在做一个项目的时候需要用到IP地址的判断,在博客园里搜索了下发现马上就找到了相关的函数,谢谢作者,原文作者:http://www.cnblogs.com/dongyi/