Compares two Uri instances for equality.
Assembly: System (in System.dll)
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)] public override bool Equals( Object comparand )
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.
If one Uri instance is formed with a Unicode host name and comparand parameter contains a Uri instance or identifier that is formed with a host name that has the equivalent Punycode host name, then returns true only if International Resource Identifier (IRI) and Internationalized Domain Name (IDN) support are enabled. Punycode names contain only ASCII characters and always start with the xn-- prefix.
For more information on IRI support, see the Remarks section for the Uri class.
In the .NET Framework versions 1.0 and 1.1, the Query is also ignored.
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)) Console.WriteLine("The two addresses are equal"); else Console.WriteLine("The two addresses are not equal");
// Create some Uris. Uri* address1 = new Uri(S"http://www.contoso.com/index.htm#search"); Uri* address2 = new Uri(S"http://www.contoso.com/index.htm"); if (address1->Equals(address2)) Console::WriteLine(S"The two addresses are equal"); else Console::WriteLine(S"The two addresses are not equal");
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.