本文整理汇总了C#中Contact.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.Equals方法的具体用法?C# Contact.Equals怎么用?C# Contact.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComparisonWithIIdentifiable
public void ComparisonWithIIdentifiable()
{
Contact newcontact = new Contact();
Contact existingcontact = Data<Contact>.RetrieveFirst();
//compare to other == false
Assert.IsFalse(newcontact.Equals(existingcontact));
//compare to null == false
Assert.IsFalse(newcontact.Equals(null));
//compare to self == true
Assert.IsTrue(newcontact.Equals(newcontact));
//compare to another new object == true
//it's true because autotrack is off and we didn't initialize key field, so both are default and equal
Contact newcontact2 = new Contact();
Assert.IsTrue(newcontact.Equals(newcontact2));
//compare to the same contact loaded from the database == true
Contact existingcontact2 = Data<Contact>.RetrieveFirst();
Assert.IsTrue(existingcontact.Equals(existingcontact2));
//compare to the same contact loaded from the database with changes to non-key field == true
//this is true because Contact implements IIdentifiable, which uses IIdentity fields for comparison
existingcontact2.FirstName = existingcontact2.FirstName + "!";
Assert.IsTrue(existingcontact.Equals(existingcontact2));
}
示例2: ContactEqualsTrueTest
public void ContactEqualsTrueTest()
{
Contact first = new Contact("Pesho", "Sofia", "088123456");
Contact second = new Contact("Pesho", "Sofia", "088123456");
bool equal = first.Equals(second);
Assert.IsTrue(equal);
}
示例3: ContactEqualsFalseTest
public void ContactEqualsFalseTest()
{
Contact first = new Contact("Pesho", "Sofia", "088123456");
Contact second = new Contact("Jorko", "Plovdiv", "0888654321");
bool equal = first.Equals(second);
Assert.IsFalse(equal);
}