Leer en inglés

Compartir a través de


Uri.Fragment Propiedad

Definición

Obtiene el fragmento de URI de escape, incluido el carácter "#" inicial si no está vacío.

C#
public string Fragment { get; }

Valor de propiedad

Información del fragmento de URI.

Excepciones

Esta instancia representa un identificador URI relativo, y esta propiedad sólo es válida para identificadores URI absolutos.

Ejemplos

En el ejemplo siguiente se crea una Uri instancia y se escribe la información del fragmento en la consola.

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

Comentarios

La Fragment propiedad obtiene cualquier texto después de un marcador de fragmento (#) en el URI, incluido el propio marcador de fragmento. Dado el URI http://www.contoso.com/index.htm#main, la Fragment propiedad devolvería #main.

La Fragment propiedad no se considera en ninguna Equals comparación.

Se aplica a

Producto Versiones
.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