共用方式為


IPAddressInformation 類別

定義

提供網路介面位址的相關資訊。

public ref class IPAddressInformation abstract
public abstract class IPAddressInformation
type IPAddressInformation = class
Public MustInherit Class IPAddressInformation
繼承
IPAddressInformation
衍生

範例

下列程式代碼範例會顯示本機計算機上網路介面的域名服務 (DNS) 位址。

void DisplayDnsAddresses()
{
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum11 = adapters->GetEnumerator();
   while ( myEnum11->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum11->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      IPAddressCollection ^ dnsServers = adapterProperties->DnsAddresses;
      if ( dnsServers->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum12 = dnsServers->GetEnumerator();
         while ( myEnum12->MoveNext() )
         {
            IPAddress ^ dns = safe_cast<IPAddress ^>(myEnum12->Current);
            Console::WriteLine( "  DNS Servers ............................. : {0}", 
               dns->ToString());
         }
      }
   }
}
public static void DisplayDnsAddresses()
{
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {

        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        IPAddressCollection dnsServers = adapterProperties.DnsAddresses;
        if (dnsServers.Count > 0)
        {
            Console.WriteLine(adapter.Description);
            foreach (IPAddress dns in dnsServers)
            {
                Console.WriteLine("  DNS Servers ............................. : {0}",
                    dns.ToString());
            }
            Console.WriteLine();
        }
    }
}
Public Shared Sub DisplayDnsAddresses() 
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim dnsServers As IPAddressCollection = adapterProperties.DnsAddresses
        If dnsServers.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim dns As IPAddress
            For Each dns In  dnsServers
                Console.WriteLine("  DNS Servers ............................. : {0}",dns.ToString() )
            Next dns
        End If
    Next adapter

End Sub

備註

您不會建立此類別的實例;實例會由類別中的 IPInterfaceProperties 方法傳回。

建構函式

IPAddressInformation()

初始化 IPAddressInformation 類別的新執行個體。

屬性

Address

取得網際網路通訊協定 (IP) 位址。

IsDnsEligible

取得 Boolean 值,指出網際網路通訊協定 (IP) 位址出現在網域名稱系統 (DNS) 伺服器資料庫中是否有效。

IsTransient

取得 Boolean 值,指示網際網路通訊協定 (IP) 位址是否為暫時性 (Transient) 的 (叢集位址)。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於