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


C# IEqualityComparer.GetHashCode方法代码示例

本文整理汇总了C#中IEqualityComparer.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# IEqualityComparer.GetHashCode方法的具体用法?C# IEqualityComparer.GetHashCode怎么用?C# IEqualityComparer.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEqualityComparer的用法示例。


在下文中一共展示了IEqualityComparer.GetHashCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssertCompareEqual

 static void AssertCompareEqual(IEqualityComparer<NameAndNumber> comparer, NameAndNumber x, NameAndNumber y)
 {
     Assert.IsTrue(comparer.Equals(x, y));
     Assert.IsTrue(comparer.Equals(y, x));
     if (x != null && y != null)
     {
         Assert.AreEqual(comparer.GetHashCode(x), comparer.GetHashCode(y));
     }
 }
开发者ID:dioptre,项目名称:nkd,代码行数:9,代码来源:ProjectionEqualityComparerTest.cs

示例2:

 int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) {
     object obj;
     if (TryGetObject(out obj)) {
         return comparer.GetHashCode(obj);
     }
     return comparer.GetHashCode(null);
 }
开发者ID:TerabyteX,项目名称:ironpython3,代码行数:7,代码来源:_weakref.cs

示例3: GetHashCode

 public int GetHashCode(IEqualityComparer comparer)
 {
     return comparer.GetHashCode(this);
 }
开发者ID:TryingToImprove,项目名称:EqualityPlugin-TryingToImproveMe,代码行数:4,代码来源:Customer.cs

示例4: TestComparisons

 /// <summary>
 /// Utility method to perform appropriate comparisons with the given comparer.
 /// For all tests:
 /// A10 == A10
 /// B15 == B15
 /// A10 != B15
 /// A10 != null
 /// B15 != null
 /// A10 might equal B10, and A10 might equal A15, depending on the comparer -
 /// this is in each individual test.
 /// </summary>
 static void TestComparisons(IEqualityComparer<NameAndNumber> comparer)
 {
     AssertCompareEqual(comparer, A10, A10);
     AssertCompareEqual(comparer, B15, B15);
     AssertCompareEqual(comparer, null, null);
     AssertCompareNotEqual(comparer, A10, B15);
     AssertCompareNotEqual(comparer, A10, null);
     AssertCompareNotEqual(comparer, B15, null);
     AssertCompareNotEqual(comparer, null, B15);
     AssertCompareNotEqual(comparer, null, A10);
     try
     {
         comparer.GetHashCode(null);
     }
     catch (ArgumentNullException)
     {
         // Expected
     }
 }
开发者ID:dioptre,项目名称:nkd,代码行数:30,代码来源:ProjectionEqualityComparerTest.cs


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