Why does HashSet <T> not implement ICollection?

I am going to write a library to cross an object graph (for example, some kind of serialization).
You will need to judge whether the object is a traverse collection, so ICollection gone out of my mind. ( string also implemented IEnumerable )

But it is really strange that almost all containers in collections are implemented by ICollection except HashSet only implemented ICollection<T> ...

I checked almost all common containers in the System.Collections namespace:

 ArrayList : IList, ICollection, IEnumerable, ICloneable BitArray : ICollection, IEnumerable, ICloneable Hashtable : IDictionary, ICollection, IEnumerable, ISerializable, IDeserializationCallback, ICloneable Queue : ICollection, IEnumerable, ICloneable SortedList : IDictionary, ICollection, IEnumerable, ICloneable Stack : ICollection, IEnumerable, ICloneable Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, ISerializable, IDeserializationCallback HashSet<T> : ISerializable, IDeserializationCallback, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable LinkedList<T> : ICollection<T>, IEnumerable<T>, ICollection, IEnumerable, ISerializable, IDeserializationCallback List<T> : IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable Queue<T> : IEnumerable<T>, ICollection, IEnumerable SortedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable SortedList<TKey, TValue> : IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable SortedSet<T> : ISet<T>, ICollection<T>, IEnumerable<T>, ICollection, IEnumerable, ISerializable, IDeserializationCallback Stack<T> : IEnumerable<T>, ICollection, IEnumerable 

This is mistake? Or are there some reasons?

+5
source share

All Articles