public static void Main()
string remoteIpAddress = "7.7.7.7:123";
string IPv4 = string.Empty;
string IPv6 = string.Empty;
if (remoteIpAddress.Contains(":"))
Console.WriteLine(remoteIpAddress);
string[] cleanIpAddressremoteIpAddress = remoteIpAddress.Split(':');
Console.WriteLine(remoteIpAddress.Split(':'));
if (string.IsNullOrEmpty(remoteIpAddress))
if (IPAddress.TryParse(remoteIpAddress, out address))
switch (address.AddressFamily)
case System.Net.Sockets.AddressFamily.InterNetwork:
IPv4 = address.ToString();
IPv6 = address.MapToIPv6().ToString();
case System.Net.Sockets.AddressFamily.InterNetworkV6:
IPv4 = address.MapToIPv4().ToString();
IPv6 = address.ToString();