Class EquatableDictionary<TKey, TValue>
public sealed class EquatableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable, IDeserializationCallback, ISerializable, IEquatable<ComparableDictionary<TKey, TValue>> where TKey : notnull where TValue : notnull
Type Parameters
TKeyTValue
- Inheritance
-
Dictionary<TKey, TValue>EquatableDictionary<TKey, TValue>
- Implements
-
IDictionary<TKey, TValue>ICollection<KeyValuePair<TKey, TValue>>IReadOnlyDictionary<TKey, TValue>IReadOnlyCollection<KeyValuePair<TKey, TValue>>IEnumerable<KeyValuePair<TKey, TValue>>IEquatable<ComparableDictionary<TKey, TValue>>
- Inherited Members
- Extension Methods
Methods
Equals(object?)
Determines whether the current instance is equal to the specified object by attempting to cast it to a ComparableDictionary<TKey, TValue> and delegating to the typed equality comparison. Returns false when the supplied object is not a ComparableDictionary<TKey, TValue>.
public override bool Equals(object? other)
Parameters
otherobjectThe object to compare with the current instance.
Returns
- bool
trueifotheris a ComparableDictionary<TKey, TValue> and is equal to the current instance; otherwise,false.
Equals(ComparableDictionary<TKey, TValue>?)
Determines whether the current dictionary is equal to another ComparableDictionary<TKey, TValue> by comparing their counts and key-value pairs.
Returns false if the other dictionary is null, has a different count, is missing any key present in this dictionary, or contains a different value for any shared key.
public bool Equals(ComparableDictionary<TKey, TValue>? other)
Parameters
otherComparableDictionary<TKey, TValue>The dictionary to compare against this instance.
Returns
- bool
trueif both dictionaries contain the same keys with equal values; otherwise,false.
GetHashCode()
Computes a hash code for the collection by combining the hash codes of each key-value pair. Each pair contributes a hash derived from its key and value, and the per-pair hashes are combined using XOR.
public override int GetHashCode()
Returns
- int
An integer hash code that represents the contents of the collection.