IPInterfaceProperties.AnycastAddresses Property   
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the anycast IP addresses assigned to this interface.
public:
 abstract property System::Net::NetworkInformation::IPAddressInformationCollection ^ AnycastAddresses { System::Net::NetworkInformation::IPAddressInformationCollection ^ get(); };[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }public abstract System.Net.NetworkInformation.IPAddressInformationCollection AnycastAddresses { get; }[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
member this.AnycastAddresses : System.Net.NetworkInformation.IPAddressInformationCollectionmember this.AnycastAddresses : System.Net.NetworkInformation.IPAddressInformationCollectionPublic MustOverride ReadOnly Property AnycastAddresses As IPAddressInformationCollectionProperty Value
An IPAddressInformationCollection that contains the anycast addresses for this interface.
- Attributes
Examples
The following code example displays the anycast addresses for the network interfaces on the local computer.
public static void DisplayAnycastAddresses()
{
    int count = 0;
    Console.WriteLine("Anycast Addresses");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressInformationCollection anyCast = adapterProperties.AnycastAddresses;
        if (anyCast.Count >0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddressInformation any in anyCast)
            {
                Console.WriteLine("  Anycast Address .......................... : {0} {1} {2}",
                    any.Address,
                    any.IsTransient ? "Transient" : "",
                    any.IsDnsEligible ? "DNS Eligible" : ""
                );
                count++;
            }
            Console.WriteLine();
        }
    }
    if (count == 0)
    {
        Console.WriteLine("  No anycast addressses were found.");
        Console.WriteLine();
    }
}
Public Shared Sub DisplayAnycastAddresses() 
    Dim count as Integer = 0
    
    Console.WriteLine("Anycast Addresses")
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim anyCast As IPAddressInformationCollection = adapterProperties.AnycastAddresses
        If anyCast.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim any As IPAddressInformation
            For Each any In  anyCast
                Console.WriteLine("  Anycast Address .......................... : {0} {1} {2}", any.Address, IIf(any.IsTransient, "Transient", ""), IIf(any.IsDnsEligible, "DNS Eligible", ""))
            'TODO: For performance reasons this should be changed to nested IF statements
            'TODO: For performance reasons this should be changed to nested IF statements
                count += 1
            Next any
            Console.WriteLine()
        End If
    Next adapter
    if count = 0 then
        Console.WriteLine("  No anycast addresses were found.")
        Console.WriteLine()
    End if
End Sub
Remarks
An anycast address identifies multiple computers. Packets sent to an anycast address are sent to one of the computers identified by the address. Anycast addressing is an IPv6 feature used to update router tables for a group of hosts.