public static int GetOrderedCollectionHashCode <T>(this IEnumerable <T> collection) { if (collection == null) { return(0); } int hashCode = 0; foreach (T t in collection) { hashCode = EqualityUtil.CombineHashCodes(hashCode, t.GetHashCode()); } return(hashCode); }
public static int GetOrderedDictionaryHashCode <TKey, TValue>(this IEnumerable <KeyValuePair <TKey, TValue> > dictionary) { if (dictionary == null) { return(0); } int hashCode = 0; foreach (KeyValuePair <TKey, TValue> kvp in dictionary) { hashCode = EqualityUtil.CombineHashCodes(hashCode, EqualityUtil.CombineHashCodes(kvp.Key.Hash(), kvp.Value.Hash())); } return(hashCode); }
public int GetHashCode(KeyValuePair <TKey, TValue> obj) { return(EqualityUtil.CombineHashCodes(obj.Key.Hash(), obj.Value.Hash())); }