Uri.Fragment Tulajdonság

Definíció

Lekéri a szökött URI-töredéket, beleértve a kezdő "#" karaktert, ha nem üres.

public:
 property System::String ^ Fragment { System::String ^ get(); };
public string Fragment { get; }
member this.Fragment : string
Public ReadOnly Property Fragment As String

Tulajdonság értéke

URI-töredékadatok.

Kivételek

Ez a példány relatív URI-t jelöl, és ez a tulajdonság csak abszolút URI-kra érvényes.

Példák

Az alábbi példa létrehoz egy példányt Uri , és a töredékadatokat a konzolra írja.

// 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
// Create Uri
let uriAddress = Uri "http://www.contoso.com/index.htm#search"
printfn $"{uriAddress.Fragment}"
printfn $"""Uri {if uriAddress.IsDefaultPort then "uses" else "does not use"} the default port """

printfn $"The path of this Uri is {uriAddress.GetLeftPart UriPartial.Path}"
printfn $"Hash code {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
' Create Uri
Dim uriAddress As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine(uriAddress.Fragment)
Console.WriteLine("Uri {0} the default port ", If(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

Megjegyzések

A Fragment tulajdonság az URI-ban egy töredékjelölőt (#) követő szöveget kap, beleértve magát a töredékjelölőt is. Az URI http://www.contoso.com/index.htm#mainmiatt a Fragment tulajdonság #main ad vissza.

A Fragment tulajdonság nem tekinthető összehasonlításnak Equals .

Note

A tulajdonság tartalmazza a vezető elválasztót (#), míg az URI-specifikáció (RFC 3986) az URI részeként ismeri fel az elválasztó nélkül.

A következőre érvényes: