仅仅针对于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#?的更多相关文章

  1. Windows7 Autoconfiguration IPv4 Address 导致无法上网

    Windows7 Autoconfiguration IPv4 Address 导致无法上 (2010-03-30 16:44:57) 转载▼ 标签: 杂谈 分类: 电脑软件问题 Windows7 A ...

  2. scala get ipv4 address

    scala 用 isInstanceOf 会报错(instanceof 这个函数就没有),java 下使用  instanceof 来判断是否是 Inet4Address test("get ...

  3. 【解决】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 ...

  4. 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> ...

  5. IP地址转换32为长整型

    Programming Question: Convert an IPv4 address in the format of null-terminated C string into a 32-bi ...

  6. netsh端口转发

      使用多个虚拟机,将开发环境和工作沟通环境分开(即时通,办公系统都只能在windows下使用…),将开发环境的服务提供给外部访问时,需要在主机上通过代理配置数据转发. VirtualBox提供了端口 ...

  7. .bat文件设置IP、DNS

    这几天遇到个烦心事,每次开机之后都要去手动去设置一下IP地址,一大串的数字还是有点麻烦,于是就想写个批处理文件设置IP 注意:在DOS下设置IP时需要管理员权限运行 1.查看机子设置IP需要用到的名字 ...

  8. windows下的端口转发命令netsh

    使用下面的命令查看语法 netsh interface portproxy add v4tov4 /? add v4tov4 [listenport=]<integer>|<serv ...

  9. 【Windows】netsh动态配置端口转发

    文章转载自傲风 使用多个虚拟机,将开发环境和工作沟通环境分开(即时通,办公系统都只能在windows下使用-),将开发环境的服务提供给外部访问时,需要在主机上通过代理配置数据转发. VirtualBo ...

随机推荐

  1. HttpRuntime.Cache被清空的DataTable

    将一个DataTable存到Cache中后,另一个页面新建变量并获取,操作变量,Cache中的数据也被改动了? 页面a.aspx 初始化并赋值,输出当前缓存内DataTable内数据条数 Page_L ...

  2. 使用ICSharpZipLib将文件夹压缩为zip文件

    序言:     在我接触Git和SVN之前,我最常用的保存数据的办法就是把文件夹压缩成一个zip文件,添加上时间戳.下面是我在学习C#的文件操作之后做的一个练习,使用开源的ICSharpZipLib来 ...

  3. Java 十六进制转十进制

    public static int hexToDecimal(String hex) { int decimalValue = 0; for (int i = 0; i < hex.length ...

  4. 线程池读取List<T>实例

    private static readonly Object ThisLock = new object(); private static readonly AutoResetEvent AutoR ...

  5. ubuntu netbeans compile ygopro client with google protobuf lib

    environment: ubuntu 16.04 netbeans 8.2 ygopro Fluorohydride with Irrlicht Game Engine 问题1: google pr ...

  6. Poj 3061 Subsequence(二分+前缀和)

    Subsequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12333 Accepted: 5178 Descript ...

  7. Codeforces Round #80 Div.1 D

    思路:考虑离线操作,以y为关键字排序,对于y相同的一起操作,然后考虑y的范围,当y<=sqrt(n)时,直接O(n)预处理出f[x]表示f[x]+f[x+y]+f[x+2*y]+..+f[x+k ...

  8. 深度优化LNMP之Nginx [2]

    深度优化LNMP之Nginx [2]   配置Nginx gzip 压缩实现性能优化 1.Nginx gzip压缩功能介绍        Nginx gzuo压缩模块提供了压缩文件内容的功能,用户请求 ...

  9. leetcode problem 6 ZigZag Conversion

    The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like ...

  10. Jquery div边框大全

    网址 http://jquery.malsup.com/corner/ jQuery Corner是一款jQuery的插件,最初由Dave Methvin开发,但后在Malsup同志的协助下,进行了一 ...