Baca dalam bahasa Inggris

Bagikan melalui


Uri.Fragment Properti

Definisi

Mendapatkan fragmen URI yang lolos, termasuk karakter '#' utama jika tidak kosong.

public string Fragment { get; }

Nilai Properti

Informasi fragmen URI.

Pengecualian

Instans ini mewakili URI relatif, dan properti ini hanya valid untuk URI absolut.

Contoh

Contoh berikut membuat instans Uri dan menulis informasi fragmen ke konsol.

// 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

Keterangan

Properti Fragment mendapatkan teks apa pun setelah penanda fragmen (#) di URI, termasuk penanda fragmen itu sendiri. Mengingat URI http://www.contoso.com/index.htm#main, Fragment properti akan mengembalikan #main.

Properti Fragment tidak dipertimbangkan dalam perbandingan apa pun Equals .

Berlaku untuk

Produk Versi
.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