Home » C#

C# | Uri.IsAbsoluteUri Property with Example

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

Uri.IsAbsoluteUri Property

Uri.IsAbsoluteUri Property is the instance property of Uri class which used to check that given URI is absolute or not. This property returns a boolean value. If given Uri is absolute then it returns true otherwise it returns false. This property may generate System.InvalidOperationException exception.

Syntax:

    public bool IsAbsoluteUri { get; }

Return value:

The return type of this property is Boolean, it returns a Boolean value that is true if the Uri instance is absolute; otherwise, false.

Example to demonstrate example of Uri.IsAbsoluteUri Property

using System;

class UriExample
{
    //Entry point of Program
    static public void Main()
    {
        Uri domainUri;
        
        domainUri = new Uri("https://www.includehelp.com:8082");

        if (domainUri.IsAbsoluteUri)
            Console.WriteLine("Given Uri is absolute Uri");
        else
            Console.WriteLine("Given Uri is not absolute Uri");
        
    }
}

Output

Given Uri is absolute Uri

In the above program, we created an object of Uri class initialized with the website name with port number and here we checked given Uri is absolute or not using IsAbsoluteUri property of Uri class.

Reference: Uri.IsAbsoluteUri Property



Comments and Discussions!

Load comments ↻





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