Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Uri.Fragment Property in C# with Examples

  • Last Updated : 08 Jun, 2020

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!