英語で読む

次の方法で共有


Uri.Fragment プロパティ

定義

エスケープされた URI フラグメント (空でない場合は先頭の '#' 文字を含む) を取得します。

C#
public string Fragment { get; }

プロパティ値

URI フラグメント情報。

例外

このインスタンスは相対 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

注釈

プロパティは Fragment 、フラグメント マーカー自体を含め、URI 内のフラグメント マーカー (#) の後に続く任意のテキストを取得します。 URI http://www.contoso.com/index.htm#mainを指定すると、 プロパティは Fragment #メインを返します。

プロパティは Fragment 比較では Equals 考慮されません。

適用対象

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