当前位置: 首页>>代码示例>>C#>>正文


C# Contact.Equals方法代码示例

本文整理汇总了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));
		}
开发者ID:cnporras,项目名称:wilsonormapper,代码行数:28,代码来源:EntityTests.cs

示例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);
        }
开发者ID:vanndann,项目名称:TelerikAcademy,代码行数:8,代码来源:ContactTests.cs

示例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);
        }
开发者ID:vanndann,项目名称:TelerikAcademy,代码行数:8,代码来源:ContactTests.cs


注:本文中的Contact.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。