DNS Name and Its IPHostEntry : DNS : Network C# Examples


C# Examples » Network » DNS »

 

DNS Name and Its IPHostEntry









    
using  System;
using  System.Net;

class  MainClass
{
      public  static  void  Main()
      {
            string  hostName  =  Dns.GetHostName();
            Console.WriteLine("Local  hostname:  {0}",  hostName);
            IPHostEntry  myself  =  Dns.GetHostByName(hostName);
            foreach  (IPAddress  address  in  myself.AddressList)
            {
                  Console.WriteLine("IP  Address:  {0}",  address.ToString());
            }
      }
}
    
   
  
   



Output

Local hostname: navioo
IP Address: 192.168.1.101


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» DNS