CSharpTest.Net
Equals(Password,Password) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Equals Method : Equals(Password,Password) Method

x
y

Glossary Item Box

Compares the two objects for non-reference equality

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function Equals( _
   ByVal x As Password, _
   ByVal y As Password _
) As Boolean
C# 
public static bool Equals( 
   Password x,
   Password y
)

Parameters

x
y

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.NETCopy 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

Generated with Document! X 2011 by Innovasys