How to convert an IPv4 address into a integer in C#?
仅仅针对于IPv4的处理方法
从string转换为int
以及从int转换为string
// IPv4
int intAddress = BitConverter.ToInt32(IPAddress.Parse(address).GetAddressBytes(), 0);
string ipAddress = new IPAddress(BitConverter.GetBytes(intAddress)).ToString();
EDIT: As noted in other answers, when running this snippet on a little endian machine, it'll give out the bytes in the reverse order as defined by the standard. However, the question asks for a mapping between an integer and an IP address, not converting to the standard integer format. To do so, you have to consider the endian-ness of the machine you're running on.
How to convert an IPv4 address into a integer in C#?的更多相关文章
- Windows7 Autoconfiguration IPv4 Address 导致无法上网
Windows7 Autoconfiguration IPv4 Address 导致无法上 (2010-03-30 16:44:57) 转载▼ 标签: 杂谈 分类: 电脑软件问题 Windows7 A ...
- scala get ipv4 address
scala 用 isInstanceOf 会报错(instanceof 这个函数就没有),java 下使用 instanceof 来判断是否是 Inet4Address test("get ...
- 【解决】could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
在同一套环境中跑了很多个项目都是用 docker-compose的方式启动的,导致创建的自定义网络过多出现下面的报错 Error response from daemon: could not fin ...
- docker could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network
原因: 无法进行网络分配了 解决方法: // 所有的网络 docker network ls // 删除不用的,腾出多余的 docker network rm <networkname> ...
- IP地址转换32为长整型
Programming Question: Convert an IPv4 address in the format of null-terminated C string into a 32-bi ...
- netsh端口转发
使用多个虚拟机,将开发环境和工作沟通环境分开(即时通,办公系统都只能在windows下使用…),将开发环境的服务提供给外部访问时,需要在主机上通过代理配置数据转发. VirtualBox提供了端口 ...
- .bat文件设置IP、DNS
这几天遇到个烦心事,每次开机之后都要去手动去设置一下IP地址,一大串的数字还是有点麻烦,于是就想写个批处理文件设置IP 注意:在DOS下设置IP时需要管理员权限运行 1.查看机子设置IP需要用到的名字 ...
- windows下的端口转发命令netsh
使用下面的命令查看语法 netsh interface portproxy add v4tov4 /? add v4tov4 [listenport=]<integer>|<serv ...
- 【Windows】netsh动态配置端口转发
文章转载自傲风 使用多个虚拟机,将开发环境和工作沟通环境分开(即时通,办公系统都只能在windows下使用-),将开发环境的服务提供给外部访问时,需要在主机上通过代理配置数据转发. VirtualBo ...
随机推荐
- 20151221jquery学习笔记---日历UI
妹的,这几天真是无语了,参加了一个无聊的比赛,简直浪费时间,好几天没学jquery啊,今天学了一点,不过快要期末考试了,估计得攒到寒假了啊. 日历(datepicker) UI, 可以让用户更加直观的 ...
- android.util.AndroidRuntimeException: requestFeature() must be called before adding content解决办法
最近在学习第一行代码这本书,里面的关于activity生命周期有一段例子,但是我自己用mac上装的as运行一直出问题,看log的话就是android.util.AndroidRuntimeExcept ...
- Hyper-V Windows 8.1 & Windows Server 2012 R2 Q&A
从Windows8开始,x64位系统自带Hyper-V功能,很多开发者和专业用户往往希望利用的Microsoft提供的这一免费功能,但是微软在这方面并不是最佳. 主要写几个大家经常遇到的问题. Win ...
- web服务器压力测试工具
http_load 是运行在linux操作系统上的命令行测试工具, 用来对网站做压力测试. 下载地址:http://www.acme.com/software/http_load/http_load- ...
- ios应用来电监听
先导入这两个头文件,库文件不用导可以 #import <CoreTelephony/CTCallCenter.h> #import <CoreTelephony/CTCall.h&g ...
- java三大特性性:封装、继承和多态
一.封装 封装是指隐藏对象的属性及实现细节,对外仅提供接口可见.封装实现了信息隐藏,利于软件复用.其优点是达到了模块化的标准,从而提高了代码的复用程度.在某种程度上,封装也大大改善了软件开发的可维护性 ...
- Speak softly love
Speak softly love and hold me warm against your heart 柔声诉情,拥我在你暖暖的心上 I feel your words, the tender t ...
- 【BZOJ3270】【高斯消元】博物馆
Description 有一天Petya和他的朋友Vasya在进行他们众多旅行中的一次旅行,他们决定去参观一座城堡博物馆.这座博物馆有着特别的样式.它包含由m条走廊连接的n间房间,并且满足可以从任何一 ...
- tomcat server.xml配置文件 解析
把服务拆分出来了. 前几天我也进行了拆分.可是当时服务起不来所以我想会不会有什么设置,使得这个服务在主机中只能启一个.然后我又找了一台服务器,也把代码放了进去.结果仿佛是我料想到的样子, ...
- github 查看单个文件的历史记录命令
gitk 安装: apt-get install gitk 点击打开链接http://stackoverflow.com/questions/278192/view-the-change-histor ...