C# Dns Resolve

Description

Dns Resolve Resolves a DNS host name or IP address to an IPHostEntry instance.

Syntax

Dns.Resolve has the following syntax.


[ObsoleteAttribute("Resolve is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public static IPHostEntry Resolve(
  string hostName
)

Parameters

Dns.Resolve has the following parameters.

  • hostName - A DNS-style host name or IP address.

Returns

Dns.Resolve method returns An IPHostEntry instance that contains address information about the host specified in hostName.

Example


using System;/* ww  w .java2 s.c o  m*/
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {
         IPHostEntry hostInfo = Dns.Resolve("google.com");
         IPAddress[] address = hostInfo.AddressList;
         String[] alias = hostInfo.Aliases;

         for(int index=0; index < alias.Length; index++) {
           Console.WriteLine(alias[index]);
         } 
         for(int index=0; index < address.Length; index++) {
            Console.WriteLine(address[index]);
         }
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient