Home » C#

C# | Uri.Fragment Property with Example

Uri.Fragment Property: Here, we are going to learn about the Fragment Property of Uri class with example in C#.
Submitted by Nidhi, on March 28, 2020

Uri.Fragment Property

Uri.Fragment Property is instance property of Uri class which used to get a un-escaped fragment from URI. This property returns a string value. This property may generate System.InvalidOperationException exception.

Syntax:

    public string Fragment { get; }

Return value:

The return type of this property is string, it returns a string that contains any URI fragment information.

Example to demonstrate example of Uri.Fragment Property

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri;
        
        domainUri = new Uri("https://www.includehelp.com/home.html#C-Articles");
        
        Console.WriteLine("Uri Fragment: "+ domainUri.Fragment);
    }
}

Output

Uri Fragment: #C-Articles

In the above program, we created an object of Uri class initialized with URI that contains fragment "#C-Articles" and we got a un-escaped fragment using Fragment property.

Reference: Uri.Fragment Property



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.