博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to convert an IPv4 address into a integer in C#?
阅读量:4663 次
发布时间:2019-06-09

本文共 636 字,大约阅读时间需要 2 分钟。

 

仅仅针对于IPv4的处理方法

从string转换为int

以及从int转换为string

// IPv4int 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.

 

转载于:https://www.cnblogs.com/chucklu/p/4789215.html

你可能感兴趣的文章
使用python selenium webdriver模拟浏览器
查看>>
session 、cookie、token的区别
查看>>
Python-生成器_36
查看>>
mysql慢查询日志分析
查看>>
HTTP从入门到入土(4)——URI、URL和URN
查看>>
photoshop自动切图,导出svg,支持阿里巴巴图标库上传相互转换
查看>>
UI事件 计算器界面
查看>>
lucene简单使用demo
查看>>
实验三
查看>>
敏捷开发
查看>>
Visual Studio 2017离线安装包,百度云分流
查看>>
【SAS BASE】SAS格式、缺失值表示、命名规则及路径
查看>>
杭电2096
查看>>
程序员不得不知的座右铭(中国篇)
查看>>
中国大学MOOC-数据结构基础习题集、06-4、How Long Does It Take
查看>>
第四章 串的基本操作【数据结构】
查看>>
嵌入式系统
查看>>
web前端面试题
查看>>
冲刺第十九天
查看>>
POJ 2376 Cleaning Shifts
查看>>