1.将IP地址转化为整形
System.Net.IPAddress ip= System.Net.IPAddress.Parse("192.168.1.2");
int iplong =(int) ip.Address;
2.将整型变为IP地址
int j=23543;
System.Net.IPAddress ip1= System.Net.IPAddress.Parse(j.ToString());
this.Label1.Text=ip1.ToString();
//IP地址
string Ip = "123.130.130.129";
//取出IP地址去掉‘.’后的string数组
string[] Ip_List = Ip.Split(".".ToCharArray());
string X_Ip = "";
//循环数组,把数据转换成十六进制数,并合并数组(3dafe81e)
foreach (string ip in Ip_List)
{
X_Ip += Convert.ToInt16(ip).ToString("x");
}
//将十六进制数转换成十进制数(1034938398)
long N_Ip = long.Parse(X_Ip, System.Globalization.NumberStyles.HexNumber);
Response.Write(N_Ip.ToString());