英語で読む

次の方法で共有


Uri.IsDefaultPort プロパティ

定義

URI のポート値が、このスキームの既定のポート値かどうかを示す値を取得します。

C#
public bool IsDefaultPort { get; }

プロパティ値

Boolean

true プロパティ内の値がこのスキームの Port 既定のポートの場合は .。それ以外の場合は . false

例外

このインスタンスは相対 URI を表します。このプロパティは、絶対 URI でのみ有効です。

次の例では、インスタンスを Uri 作成し、既定のポートを使用するかどうかを確認します。

C#
// Create Uri
Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");

Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
// The example displays output similar to the following:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291

適用対象

製品 バージョン
.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
.NET Framework 1.1, 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
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0