IPInterfaceProperties.DhcpServerAddresses 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 addresses of Dynamic Host Configuration Protocol (DHCP) servers for this interface.
public:
 abstract property System::Net::NetworkInformation::IPAddressCollection ^ DhcpServerAddresses { System::Net::NetworkInformation::IPAddressCollection ^ get(); };[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("freebsd")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("osx")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }public abstract System.Net.NetworkInformation.IPAddressCollection DhcpServerAddresses { get; }[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("freebsd")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("osx")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollectionmember this.DhcpServerAddresses : System.Net.NetworkInformation.IPAddressCollectionPublic MustOverride ReadOnly Property DhcpServerAddresses As IPAddressCollectionProperty Value
An IPAddressCollection that contains the address information for DHCP servers, or an empty array if no servers are found.
- Attributes
Examples
The following code example displays the DHCP address information for the network interfaces on the local computer.
public static void DisplayDhcpServerAddresses()
{
    Console.WriteLine("DHCP Servers");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressCollection addresses = adapterProperties.DhcpServerAddresses;
        if (addresses.Count >0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddress address in addresses)
            {
                Console.WriteLine("  Dhcp Address ............................ : {0}",
                    address.ToString());
            }
            Console.WriteLine();
        }
    }
}
Public Shared Sub DisplayDhcpServerAddresses() 
    Console.WriteLine("DHCP Servers")
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim addresses As IPAddressCollection = adapterProperties.DhcpServerAddresses
        If addresses.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim address As IPAddress
            For Each address In  addresses
                Console.WriteLine("  Dhcp Address ............................ : {0}", address.ToString())
            Next address
            Console.WriteLine()
        End If
    Next adapter
End Sub
Remarks
Dynamic Host Configuration Protocol (DHCP) allows a computer to obtain a network address from a DHCP server, as opposed to using a static (fixed) network address. A DHCP server does not permanently assign addresses; instead, it temporarily uses one of a number of available addresses to the computer.