Bagikan melalui


IPAddressInformation Kelas

Definisi

Menyediakan informasi tentang alamat antarmuka jaringan.

public ref class IPAddressInformation abstract
public abstract class IPAddressInformation
type IPAddressInformation = class
Public MustInherit Class IPAddressInformation
Warisan
IPAddressInformation
Turunan

Contoh

Contoh kode berikut menampilkan alamat Layanan Nama Domain (DNS) untuk antarmuka jaringan di komputer lokal.

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

Keterangan

Anda tidak membuat instans kelas ini; instans dikembalikan oleh metode di IPInterfaceProperties kelas .

Konstruktor

IPAddressInformation()

Menginisialisasi instans baru kelas IPAddressInformation.

Properti

Address

Mendapatkan alamat Protokol Internet (IP).

IsDnsEligible

Boolean Mendapatkan nilai yang menunjukkan apakah alamat Protokol Internet (IP) valid untuk muncul dalam database server Sistem Nama Domain (DNS).

IsTransient

Boolean Mendapatkan nilai yang menunjukkan apakah alamat Protokol Internet (IP) bersifat sementara (alamat kluster).

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk