Uri.Fragment Property

Gets the escaped URI fragment.

Namespace:  System
Assembly:  System (in System.dll)

public string Fragment { get; }

Property Value

Type: System.String
A String that contains any URI fragment information.

ExceptionCondition
InvalidOperationException

This property is valid only for an absolute Uri instance.

The 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 Fragment property would return #main.

The Fragment property is not considered in any Equals comparison.

The following example creates a Uri instance and writes the fragment information to the console.


// Create Uri
Uri uriAddress1 = new Uri("http://www.contoso.com/index.htm#search");
outputBlock.Text += uriAddress1.Fragment;
outputBlock.Text += "\n";

outputBlock.Text += "Hash code: ";
outputBlock.Text += uriAddress1.GetHashCode();
outputBlock.Text += "\n";


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft