July 28, 2014
Compares two Uri instances for equality.
Assembly: System (in System.dll)
The method compares the two instances without regard to user information (UserInfo) and fragment (Fragment) parts that they might contain. For example, given the URIs http://www.contoso.com/index.htm#search and http://user:email@example.com/index.htm, the method would return true.
The method can be overridden in a derived class; use caution as a malicious entity could modify the method. You should not use this method to perform security checks unless you know that this instance came from a trusted source.
This example creates two 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.
// Create some Uris. Uri address1 = new Uri("http://www.contoso.com/index.htm#search"); Uri address2 = new Uri("http://www.contoso.com/index.htm"); if (address1.Equals(address2)) outputBlock.Text += "The two addresses are equal\n"; else outputBlock.Text += "The two addresses are not equal\n";