

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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.MakeRelativeUri(Uri) Method in C#
The Uri.MakeRelativeUri(Uri) method in C# is used to determine the difference between two Uri instances.
Syntax
Following is the syntax −
public Uri MakeRelativeUri (Uri uri);
Above, the URI is the URI to compare to the current URI.
Example
Let us now see an example to implement the Uri.MakeRelativeUri(Uri) method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.tutorialspoint.com/java.htm"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); Uri res = newURI1.MakeRelativeUri(newURI2); Console.WriteLine("Relative uri = "+res); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/ URI = https://www.tutorialspoint.com/java.htm Both the URIs aren't equal! Relative uri = java.htm
Example
Let us now see another example to implement the Uri.MakeRelativeUri(Uri) method −
using System; public class Demo { public static void Main(){ Uri newURI1 = new Uri("https://www.tutorialspoint.com/"); Console.WriteLine("URI = "+newURI1); Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd"); Console.WriteLine("URI = "+newURI2); if(newURI1.Equals(newURI2)) Console.WriteLine("Both the URIs are equal!"); else Console.WriteLine("Both the URIs aren't equal!"); Uri res = newURI1.MakeRelativeUri(newURI2); Console.WriteLine("Relative uri = "+res); } }
Output
This will produce the following output −
URI = https://www.tutorialspoint.com/ URI = https://www.tutorialspoint.com/jquery.htm#abcd Both the URIs aren't equal! Relative uri = jquery.htm#abcd
- Related Questions & Answers
- Uri.IsBaseOf(Uri) Method in C#
- Difference Between URL and URI
- Convert Image to Data URI with JavaScript
- How to get file URI reference in Java?
- State the differences between URI and URL in Computer Network.
- How to do Web API versioning with URI in C# ASP.NET WebAPI?
- Class method vs static method in Python
- Collections.replaceAll() method and List.replaceAll() method in Java
- Method overloading v/s method overriding in Java
- The isEmpty() method of CopyOnWriteArrayList method in Java
- The hashCode() method of CopyOnWriteArrayList method in Java
- The clone() method of CopyOnWriteArrayList method in Java
- Default method vs static method in an interface in Java?
- Difference between Method Overriding and Method Hiding in C#
- Method overloading in Java
Advertisements