IPv6InterfaceProperties 類別

定義

提供支援網際網路通訊協定第 6 版 (IPv6) 之網路介面的相關資訊。

C#
public abstract class IPv6InterfaceProperties
繼承
IPv6InterfaceProperties

範例

下列程式代碼範例會取得 IPInterfaceProperties 物件,並顯示其數據。

C#
public static void DisplayIPv6NetworkInterfaces()
{
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    Console.WriteLine("IPv6 interface information for {0}.{1}",
       properties.HostName, properties.DomainName);

    int count = 0;

    foreach (NetworkInterface adapter in nics)
    {
        // Only display informatin for interfaces that support IPv6.
        if (!adapter.Supports(NetworkInterfaceComponent.IPv6))
        {
            continue;
        }

        count++;

        Console.WriteLine();
        Console.WriteLine(adapter.Description);
        // Underline the description.
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));

        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        // Try to get the IPv6 interface properties.
        IPv6InterfaceProperties p = adapterProperties.GetIPv6Properties();

        if (p == null)
        {
            Console.WriteLine("No IPv6 information is available for this interface.");
            Console.WriteLine();
            continue;
        }
        // Display the IPv6 specific data.
        Console.WriteLine("  Index ............................. : {0}", p.Index);
        Console.WriteLine("  MTU ............................... : {0}", p.Mtu);
    }

    if (count == 0)
    {
        Console.WriteLine("  No IPv6 interfaces were found.");
        Console.WriteLine();
    }
}

備註

這個類別可讓您存取支援 IPv6 之網路介面的組態和地址資訊。 您不會建立此類別的實例;方法會傳 GetIPv6Properties 回它們。

如需 IPV4 屬性,請參閱 GetIPv4Properties

建構函式

IPv6InterfaceProperties()

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

屬性

Index

取得與網際網路通訊協定第 6 版 (IPv6) 位址相關聯的網路介面的索引。

Mtu

取得這個網路介面的最大傳輸單位 (MTU)。

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetScopeId(ScopeLevel)

取得與網際網路通訊協定第 6 版 (IPv6) 位址相關聯的網路介面的範圍 ID。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1