Compares the two objects for non-reference equality
Syntax
Example
Library/Library.Test/TestPassword.cs
C# | Copy Code |
---|
using (Password pwd1 = new Password(TEST_PASSWORD))
{
using (Password pwd2 = new Password(TEST_PASSWORD))
{
Assert.AreEqual(pwd1, pwd2);
Assert.IsTrue(Password.Equals(pwd1, pwd2));
Assert.IsTrue(pwd1 == pwd2);
Assert.IsFalse(pwd1 != pwd2);
Assert.IsTrue(pwd1.Equals(pwd2));
Assert.IsTrue(pwd1.Equals((object)pwd2));
Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
}
Assert.IsFalse(pwd1 == new Password("Not the same"));
Assert.IsFalse(pwd1 == null);
Assert.IsFalse(null == pwd1);
Assert.IsFalse(pwd1.Equals(null));
Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1));
} |
VB.NET | Copy Code |
---|
Using pwd1 As New Password(TEST_PASSWORD)
Using pwd2 As New Password(TEST_PASSWORD)
Assert.AreEqual(pwd1, pwd2)
Assert.IsTrue(Password.Equals(pwd1, pwd2))
Assert.IsTrue(pwd1 = pwd2)
Assert.IsFalse(pwd1 <> pwd2)
Assert.IsTrue(pwd1.Equals(pwd2))
Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
End Using
Assert.IsFalse(pwd1 = New Password("Not the same"))
Assert.IsFalse(pwd1 = Nothing)
Assert.IsFalse(Nothing = pwd1)
Assert.IsFalse(pwd1.Equals(Nothing))
Assert.AreEqual(pwd1.GetHashCode(), Password.GetHashCode(pwd1))
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also