Uri.Fragment Property is instance property which is used to get the escaped URI fragment.
Syntax:
public string Fragment { get; }
Return value: This property returns string that contains any URI fragment information.
Exception: This property throws InvalidOperationException for a relative URI and is valid only for absolute URIs.
Example 1:
C#
// C# program to demonstrate the // Uri.Fragment property using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
// using Fragment property
Console.WriteLine( "Uri Fragment: " + v1.Fragment);
}
} |
Output:
Uri Fragment: #standardGreedyAlgorithms
Example 2:
C#
// C# program to demonstrate the // Uri.Fragment property using System;
using System.Globalization;
class GFG {
// Main Method
public static void Main()
{
// Declaring and initializing value1
Uri v1 = new Uri( "https://www.geeksforgeeks.org/greedy-algorithms/amp/#approximateGreedyAlgorthms" );
// using Fragment property
Console.WriteLine( "Uri Fragment: " + v1.Fragment);
}
} |
Output:
Uri Fragment: #approximateGreedyAlgorthms
Article Tags :