zoukankan      html  css  js  c++  java
  • Comparer

      public class FillOneDollarShareComparer : IEqualityComparer<FillOneDollarShareEntity>
            {
                // Products are equal if their names and product numbers are equal.
                public bool Equals(FillOneDollarShareEntity x, FillOneDollarShareEntity y)
                {
    
                    //Check whether the compared objects reference the same data.
                    if (ReferenceEquals(x, y)) return true;
    
                    //Check whether any of the compared objects is null.
                    if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
                        return false;
    
                    //Check whether the products' properties are equal.
                    return x.id == y.id;
                }
    
                // If Equals() returns true for a pair of objects 
                // then GetHashCode() must return the same value for these objects.
    
                public int GetHashCode(FillOneDollarShareEntity entity)
                {
                    //Check whether the object is null
                    if (ReferenceEquals(entity, null)) return 0;
    
                    //Get hash code for the Name field if it is not null.
                    int hashID = entity.id.GetHashCode();
    
                    //Calculate the hash code for the product.
                    return hashID;
                }
            }
  • 相关阅读:
    泰勒综合
    滤波器、窗等的系数为什么是对称的?
    l'alphabet en francais
    弄清for循环的本质
    js中的闭包
    js中用正则表达式
    java Calendar
    Android实现XML解析技术
    junit4 详解
    redhat vi 命令
  • 原文地址:https://www.cnblogs.com/FH-cnblogs/p/5718230.html
Copyright © 2011-2022 走看看