string ipAddressString = "192.168.1.1"; IPAddress ipAddress = IPAddress.Parse(ipAddressString);
string hostName = "www.example.com"; IPAddress[] addresses = Dns.GetHostAddresses(hostName); IPAddress ipAddress = addresses.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);These examples use the System.Net package library.