C# Dns GetHostAddresses
Description
Dns GetHostAddresses
Returns the Internet Protocol
(IP) addresses for the specified host.
Syntax
Dns.GetHostAddresses
has the following syntax.
public static IPAddress[] GetHostAddresses(
string hostNameOrAddress
)
Parameters
Dns.GetHostAddresses
has the following parameters.
hostNameOrAddress
- The host name or IP address to resolve.
Returns
Dns.GetHostAddresses
method returns
Example
using System;/*from ww w.j a va 2 s. co 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.