IPAddressInformation.Address Property

 

Gets the Internet Protocol (IP) address.

Namespace:   System.Net.NetworkInformation
Assembly:  System (in System.dll)

public abstract IPAddress Address { get; }

Property Value

Type: System.Net.IPAddress

An IPAddress instance that contains the IP address of an interface.

The IP address uniquely identifies the interface on the network.

The following code example displays the multicast addresses for the network interfaces on the local computer.

public static void DisplayMulticastAddresses()
{
    int count = 0;

    Console.WriteLine("Multicast Addresses");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        MulticastIPAddressInformationCollection multiCast = adapterProperties.MulticastAddresses;
        if (multiCast.Count > 0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddressInformation multi in multiCast)
            {
                Console.WriteLine("  Multicast Address ....................... : {0} {1} {2}", 
                    multi.Address,
                    multi.IsTransient ? "Transient" : "", 
                    multi.IsDnsEligible ? "DNS Eligible" : ""
                );
                count++;
            }
            Console.WriteLine();
        }
    }
    if (count == 0)
    {
        Console.WriteLine("  No multicast addressses were found.");
        Console.WriteLine();
    }
}

.NET Framework
Available since 2.0
Return to top
Show: