C# Dns GetHostEntry(String)

Description

Dns GetHostEntry(String) Resolves a host name or IP address to an IPHostEntry instance.

Syntax

Dns.GetHostEntry(String) has the following syntax.


public static IPHostEntry GetHostEntry(
  string hostNameOrAddress
)

Parameters

Dns.GetHostEntry(String) has the following parameters.

  • hostNameOrAddress - The host name or IP address to resolve.

Returns

Dns.GetHostEntry(String) method returns An IPHostEntry instance that contains address information about the host specified in hostNameOrAddress.

Example

The following example uses the GetHostEntry method to resolve an IP address to an IPHostEntry instance.


//ww w  . j ava 2 s .com
using System;
using System.Net;

public class MainClass
{
    public static void Main(String[] argv)
    {
        IPHostEntry host;

        host = Dns.GetHostEntry("google.com");

        foreach (IPAddress ip in host.AddressList)
        {
            Console.WriteLine("    {0}", ip);
        }
    }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient