UriBuilder.Fragment Propiedad

Definición

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

public:
 property System::String ^ Fragment { System::String ^ get(); void set(System::String ^ value); };
public string Fragment { get; set; }
member this.Fragment : string with get, set
Public Property Fragment As String

Valor de propiedad

Parte correspondiente al campo de la dirección URI.

Ejemplos

En el ejemplo siguiente se crea el URI "http://www.contoso.com/index.htm#main".

UriBuilder^ uBuild = gcnew UriBuilder( "http://www.contoso.com/" );
uBuild->Path = "index.htm";
uBuild->Fragment = "main";
Uri^ myUri = uBuild->Uri;
UriBuilder uBuild = new UriBuilder("http://www.contoso.com/");
uBuild.Path = "index.htm";
uBuild.Fragment = "main";

Uri myUri = uBuild.Uri;
open System

let uBuild = UriBuilder "http://www.contoso.com/"
uBuild.Path <- "index.htm"
uBuild.Fragment <- "main"

let myUri = uBuild.Uri
Dim uBuild As New UriBuilder("http://www.contoso.com/")
uBuild.Path = "index.htm"
uBuild.Fragment = "main"
        
Dim myUri As Uri = uBuild.Uri

Comentarios

La Fragment propiedad contiene cualquier texto después de un marcador de fragmento (#) en el URI, incluido el propio marcador. Al establecer la Fragment propiedad :

  • En .NET Framework, el marcador de fragmento siempre se antepone a la cadena, incluso si ya existe uno.
  • En .NET 5 (y .NET Core) y versiones posteriores, el marcador de fragmento se antepone a la cadena si aún no está presente.

Nota

Para anexar un valor a un fragmento existente en .NET Framework, debe quitar el marcador de fragmento inicial antes de establecer la propiedad con el nuevo valor. Esto se debe a que .NET Framework siempre antepone el marcador de fragmento al establecer la propiedad . .NET 5 (y .NET Core) y versiones posteriores son tolerantes a un marcador de fragmento inicial y solo anteponerán uno si es necesario.

Se aplica a