IPAddressInformation.IsDnsEligible 屬性

定義

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

C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public abstract bool IsDnsEligible { get; }
C#
public abstract bool IsDnsEligible { get; }

屬性值

如果位址可以出現在 DNS 資料庫中則為 true,否則為 false

屬性

範例

下列程式代碼範例會顯示本機電腦上的網路介面的任何廣播位址。

C#
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();
    }
}

備註

範圍 169.254.0.0 到 169.254.255.255 中的位址不符合 DNS 資格。 這些位址會保留給自動私人IP尋址 (APIPA) 。

適用於

產品 版本
.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