如何将IPv4地址转换成C#中的整数

2025-04-28 18:44:27
推荐回答(1个)
回答1:

// IPv4

int intAddress =
BitConverter.ToInt32(IPAddress.Parse(address).GetAddressBytes(),
0);

string ipAddress = new
IPAddress(BitConverter.GetBytes(intAddress)).ToString();