public static void Main()
IPAddress ip = IPAddress.Parse("192.168.232.189");
Console.WriteLine(ip.MapToIPv4());
Console.WriteLine(ByteArrayToString(ip.GetAddressBytes()));
Console.WriteLine(Iptohex(ip.GetAddressBytes()));
public static string ByteArrayToString(byte[] ba)
string hex = BitConverter.ToString(ba);
return hex.Replace("-","");
public static string Iptohex(byte[] bytes)
string strAddress = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", bytes[0], bytes[1], bytes[2], bytes[3]);