Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does not IDictionary (non-generic) inherit from IEnumerable<DictionaryEntry>?

IDictionary<TKey, TValue> inherits from IEnumerable<KeyValuePair<TKey, TValue>>, but IDictionary for some reason doesn't inherit from IEnumerable<DictionaryEntry>. I wonder why? I hate to write this ugly .OfType<DictionaryEntry>() every time when I need to make a query against an IDictionary.

like image 961
thorn0 Avatar asked Jun 18 '10 10:06

thorn0


1 Answers

Because IDictionary is an older (pre-generics) interface. Changing it would break existing code. It is a legacy.

So the underlying issue is why are you (still) using IDictionary based classes, and can't you upgrade?

like image 79
Henk Holterman Avatar answered Sep 28 '22 07:09

Henk Holterman