C# | Uri.IsBaseOf(Uri) Method
Uri.IsBaseOf(Uri) Method is used to determine whether the current Uri instance is a base of the specified Uri instance.
Syntax: public bool IsBaseOf (Uri uri);
Here, it takes the specified Uri instance to test.
Return Value: This method returns true if the current Uri instance is a base of uri otherwise, false.
Exception: This method throws ArgumentNullException if uri is null.
Below programs illustrate the use of Uri.IsBaseOf(Uri) Method:
Example 1:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
bool value = address1.IsBaseOf(address2);
if (value)
Console.WriteLine( "address1 instance is a base" +
" of the specified address2" );
else
Console.WriteLine( "address1 instance is not a " +
"base of the specified address2" );
}
}
|
Output:
address1 instance is a base of the specified address2
Example 2:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
}
public static void get (Uri address1,
Uri address2)
{
bool value = address1.IsBaseOf(address2);
if (value)
Console.WriteLine( "address1 instance is a " +
"base of the specified address2" );
else
Console.WriteLine( "address1 instance is " +
"not a base of the specified address2" );
}
}
|
Output:
address1 instance is a base of the specified address2
address1 instance is not a base of the specified address2
Reference:
Last Updated :
04 Sep, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...