
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Uri.IsBaseOf(Uri) Method in C#
The Uri.IsBaseOf() method in C# is used to determine whether the current Uri instance is a base of the specified Uri instance.
Syntax
Following is the syntax −
public bool IsBaseOf (Uri uri);
Above, the parameter Uri is the specified Uri instance to test.
Example
Let us now see an example to implement the Uri.IsBaseOf() method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.tutorialspoint.com/"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); if(newURI1.IsBaseOf(newURI2)) Console.WriteLine("newURI1 is the base address"); else Console.WriteLine("newURI1 isn't the base address"); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/index.htm URI = https://www.tutorialspoint.com/ Both the URIs aren't equal! newURI1 is the base address
Example
Let us now see another example to implement the Uri.IsBaseOf() method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/index.htm"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.qries.com/"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); if(newURI1.IsBaseOf(newURI2)) Console.WriteLine("newURI1 is the base address"); else Console.WriteLine("newURI1 isn't the base address"); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/index.htm URI = https://www.qries.com/ Both the URIs aren't equal! newURI1 isn't the base address
Advertisements