Uri.Fragment Property in C# with Examples

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#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);  
    }  
}

chevron_right


Output:

Uri Fragment: #standardGreedyAlgorithms

Example 2:

C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);  
    }  
}

chevron_right


Output:

Uri Fragment: #approximateGreedyAlgorthms



My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.