URI stands for Uniform Resource Identifier. It is used to represent a resource on the internet. This resource may be a code snippet, an image, an API, and so on.
We can check if two URIs in C# are unequal using the inequality operator.
Uri1 != Uri2
Uri1
and Uri2
: These are the URIs we want to check to see if they are unequal.
The value returned is a boolean. The value true
is returned if they are not equal. Otherwise, the value false
is returned.
using System;class HelloWorld{static void Main(){// Create some Uri objectsUri uri1 = new Uri("https://www.educative.io/");Uri uri2 = new Uri("https://www.educative.io/");Uri uri3 = new Uri("https://www.educative.io/index.html");Uri uri4 = new Uri("https://www.educative.io/edpresso");// check if they are not equalConsole.WriteLine(uri1 != uri2); // FalseConsole.WriteLine(uri1 != uri3); // TrueConsole.WriteLine(uri1 != uri4); // True}}
!=
operator, and then print the results to the console.