C# IPHostEntry HostName

Description

IPHostEntry HostName Gets or sets the DNS name of the host.

Syntax

IPHostEntry.HostName has the following syntax.


public string HostName { get; set; }

Example


using System;/*from ww w  . j  ava  2  s . c o  m*/
using System.Net;
using System.Net.Sockets;

public class Example
{
   public static void Main()
   {

       IPHostEntry hostInfo = Dns.GetHostByName("google.com");
       Console.WriteLine("Host name : " + hostInfo.HostName);
       Console.WriteLine("IP address List : ");
       for(int index=0; index < hostInfo.AddressList.Length; index++)
       {
         Console.WriteLine(hostInfo.AddressList[index]);
       }
    
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient