C# में Uri.MakeRelativeUri(Uri) विधि का उपयोग दो उरी उदाहरणों के बीच अंतर को निर्धारित करने के लिए किया जाता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public Uri MakeRelativeUri (Uri uri);
ऊपर, यूआरआई वर्तमान यूआरआई की तुलना करने के लिए यूआरआई है।
उदाहरण
आइए अब Uri.MakeRelativeUri(Uri) पद्धति को लागू करने के लिए एक उदाहरण देखें -
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);
}
} आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
URI = https://www.tutorialspoint.com/ URI = https://www.tutorialspoint.com/java.htm Both the URIs aren't equal! Relative uri = java.htm
उदाहरण
आइए अब Uri.MakeRelativeUri(Uri) पद्धति को लागू करने के लिए एक और उदाहरण देखें -
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);
}
} आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा -
URI = https://www.tutorialspoint.com/ URI = https://www.tutorialspoint.com/jquery.htm#abcd Both the URIs aren't equal! Relative uri = jquery.htm#abcd