Get Internet Protocol (IP) addresses for the specified host in CSharp
Description
The following code shows how to get Internet Protocol (IP) addresses for the specified host.
Example
using System;/*from w w w . j a v a 2s .c o m*/
using System.Net;
using System.Net.Sockets;
public class Example
{
public static void Main()
{
IPAddress[] ips;
ips = Dns.GetHostAddresses("google.com");
foreach (IPAddress ip in ips)
{
Console.WriteLine(" {0}", ip);
}
}
}
The code above generates the following result.