将IP+Port转换成标准格式***.***.***.***:*****
来源:互联网 发布:d3.js 社交图谱 编辑:程序博客网 时间:2024/05/16 21:27
private string IPandPort(string temp)
{
string ipandport = temp;
string[] strDetail = ipandport.Split(":".ToCharArray());
string iptemp = strDetail[0];
string porttemp = strDetail[1];
string[] ipDetail = iptemp.Split(".".ToCharArray());
string ip = "";
string port="";
for (int i = 0; i < ipDetail.Length; i++)
{
if (ipDetail[i].Length < 3)
{
if (ipDetail[i].Length == 0)
{
ipDetail[i] = "000";
}
else if (ipDetail[i].Length == 1)
{
ipDetail[i] = "00" + ipDetail[i];
}
else if (ipDetail[i].Length == 2)
{
ipDetail[i] = "0" + ipDetail[i];
}
}
}
ip = ipDetail[0] + "." + ipDetail[1] + "." + ipDetail[2] + "." + ipDetail[3];
if (porttemp.Length < 5)
{
if (porttemp.Length == 1)
{
port = "0000" + porttemp;
}
else if (porttemp.Length == 2)
{
port = "000" + porttemp;
}
else if (porttemp.Length == 3)
{
port = "00" + porttemp;
}
else if (porttemp.Length == 4)
{
port = "0" + porttemp;
}
}
else
{
port = porttemp;
}
string ipport=ip+port ;
return ipport ;
}
- 将IP+Port转换成标准格式***.***.***.***:*****
- 将中国标准时间转换成"标准格式"
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- js将long日期格式转换为标准日期格式
- 把IP字符串转换为IPv4标准格式
- 将日期转换成中文 标准日期格式2013-10-11
- php将标准字符串格式时间转换成unix时间戳_strtotime
- js获取当前时间,并将标准日期格式转换成Long型
- C++ 将当前系统时间转换成标准格式的时间和时间戳
- java处理List<String>的内容将其转换成标准json格式
- [Boost]如何将UNIX风格时间转换为标准格式
- [Boost]如何将UNIX风格时间转换为标准格式
- [Boost]如何将UNIX风格时间转换为标准格式
- DLL编写教程(不错的文章)
- 如何将Flash设置成网页的最底层
- 将字符串转换成十六进制
- JQuery jsonp 使用示例
- java多线程之捕获异常
- 将IP+Port转换成标准格式***.***.***.***:*****
- Gambit 命令之 dgui createitem (1)
- 米老师的口头语
- 关键字 volatile
- 判断十六进制数据是否合法
- 激昂人生
- 职业导向训练(必修课)——摘自米老师的博客
- 楼市只涨不跌的秘密
- 写日志追踪程序运行过程