We discussed a problem with implementation of IEnumerable on Dictionary<K,V>. What type should IEnumerable.GetEnumerator().Current return? KeyValuePair<K,V> or DictionaryEntry? Same for ICollection.CopyTo. Instances of what type should be copied to the array?
We decided the following:
- IEnumerable and ICollection interface implementations will use KeyValuePair<K,V> as the item type.
- IDictionary specific members (GetEnumerator returning IDictionaryEnumerator) will use DictionaryEntry as the item type.
The reason is that we are in a process of making a change where IEnumerator<T> would extend IEnumerator. It would be very strange if walking the hierarchy from Dictionary<K,V>->IEnumerable<T>->IEnumerable we suddenly changed the type of the item returned from enumerators.