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

推荐订阅源

P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
博客园_首页
宝玉的分享
宝玉的分享
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
T
Tailwind CSS Blog
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
罗磊的独立博客
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
阮一峰的网络日志
阮一峰的网络日志
I
InfoQ
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Scott Helme
Scott Helme
B
Blog
M
MIT News - Artificial intelligence
K
Kaspersky official blog
H
Help Net Security
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
Engineering at Meta
Engineering at Meta
博客园 - 【当耐特】
L
Lohrmann on Cybersecurity
P
Privacy & Cybersecurity Law Blog
Project Zero
Project Zero
The Hacker News
The Hacker News
B
Blog RSS Feed
T
Tor Project blog

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

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/