Open In App

Uri.Fragment Property in C# with Examples

Improve
Improve
Like Article
Like
Save
Share
Report

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  
         
        // using Fragment property  
        Console.WriteLine("Uri Fragment: "+ v1.Fragment);  
    }  
}


Output:

Uri Fragment: #approximateGreedyAlgorthms


Last Updated : 08 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads