Home »
C#
C# | Uri.IsBaseOf() Method with Example
Uri.IsBaseOf() Method: Here, we are going to learn about the IsBaseOf() method of Uri class with example in C#.
Submitted by Nidhi, on March 26, 2020
Uri.IsBaseOf() Method
Uri.IsBaseOf() method is an instance method, which is used to check an object of Uri is the base of another object of Uri class. This method returns a boolean value, if the current object is base on a specified object then it returns true otherwise it returns false.
Syntax:
bool Uri.IsBaseOf(Uri uri);
Parameter(s):
- Uri uri – represents the object that may be base of current object.
Return value:
The return type of this method is boolean, if current object is base of specified object then it returns true otherwise it returns false.
Example to demonstrate example of Uri.IsBaseOf() method
using System;
class UriExample
{
//Entry point of Program
static public void Main()
{
// Create some Uri objects
Uri uri1 = new Uri("https://www.includehelp.com/");
Uri uri2 = new Uri("https://www.duggu.com/");
// Create a new Uri to check above uri are base of this uri or not.
Uri newUri = new Uri("https://www.includehelp.com/C#_Article.aspx");
//here we will check given uri is base of another Uri.
if (uri1.IsBaseOf(newUri))
Console.WriteLine("uri1 is baseof newUri");
else
Console.WriteLine("uri1 is not baseof newUri");
if (uri2.IsBaseOf(newUri))
Console.WriteLine("uri2 is baseof newUri");
else
Console.WriteLine("uri2 is not baseof newUri");
}
}
Output
uri1 is baseof newUri
uri2 is not baseof newUri