Using HashCode in .NETFramework
How to use HashCode type in full .NET, which doesn't support it
public class KeyValuePairComparer<TKey, TValue> : IEqualityComparer<KeyValuePair<TKey, TValue>>
{
public static KeyValuePairComparer<TKey, TValue> Default { get;} = new KeyValuePairComparer<TKey, TValue>();
public bool Equals(KeyValuePair<TKey, TValue> x, KeyValuePair<TKey, TValue> y) => object.Equals(x.Key, y.Key) && object.Equals(x.Value, y.Value);
public int GetHashCode(KeyValuePair<TKey, TValue> obj) => HashCode.Combine(obj.Key, obj.Value);
}IReadOnlyDictionary<string, string> first = ...
IReadOnlyDictionary<string, string> second = ...
return first.SequenceEquals(second, KeyValuePairComparer<string, string>.Default);
Last updated