C# Uri Equality
Description
Uri Equality
determines whether two Uri instances have
the same value.
Syntax
Uri.Equality
has the following syntax.
public static bool operator ==(
Uri uri1,
Uri uri2
)
Parameters
Uri.Equality
has the following parameters.
uri1
- A Uri instance to compare with uri2.uri2
- A Uri instance to compare with uri1.
Returns
Uri.Equality
method returns A Boolean value that is true if the Uri instances are equivalent; otherwise,
false.
Example
This example creates three Uri instances from strings and compares them to determine whether they represent the same value. Address1 and Address2 are the same because the Fragment portion is ignored for this comparison. The outcome is written to the console.
//w w w . j a va 2 s . com
using System;
public class MainClass{
public static void Main(String[] argv){
// Create some Uris.
Uri address1 = new Uri("http://www.java2s.com/index.htm#search");
Uri address2 = new Uri("http://www.java2s.com/index.htm");
Uri address3 = new Uri("http://www.java2s.com/index.htm?date=today");
// The first two are equal because the fragment is ignored.
if (address1 == address2)
Console.WriteLine("{0} is equal to {1}", address1.ToString(), address2.ToString());
}
}
The code above generates the following result.