System.Uri.Fragment Property

Gets the escaped URI fragment.

Syntax

public string Fragment { get; }

Value

A string containing any fragment information contained in the URI used to construct the current instance.

Remarks

The Uri.Fragment property gets any text following a fragment marker (#) in the URI, including the fragment marker itself. Given the URI http://www.contoso.com/index.htm#main, the Uri.Fragment property would return #main.

The Uri.Fragment property is not considered in any Uri.Equals(object) comparison.

Example

The following example demonstrates the use of the Uri.Fragment property.

C# Example

using System;

public class UriTest {
 public static void Main() {

 Uri baseUri = new Uri("http://www.contoso.com/");
 Uri myUri = new Uri(baseUri, "index.htm#main");
 
 Console.WriteLine(myUri.Fragment);
 }
}

The output is

#main

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0