C# IPHostEntry AddressList

Description

IPHostEntry AddressList Gets or sets a list of IP addresses that are associated with a host.

Syntax

IPHostEntry.AddressList has the following syntax.


public IPAddress[] AddressList { get; set; }

Example

The following example uses the AddressList property to access the IP addresses that are associated with the IPHostEntry.


using System;// w w  w  .j ava2s .co  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