I suppose this doesn’t really matter, I’m just curious.
If the difference between dictionary and lookup is one is one-to-one and the other one-to-many, wouldn’t dictionary by a more specific/derived version of the other?
A lookup is a collection of key/value pairs where the key can be repeated.
A dictionary is a collection of key/value pairs where the key cannot be repeated.
Why couldn’t IDictionary implement ILookup?
I suspect this is mainly because the intention is different.
ILookup<T,U>is designed specifically to work with a collection of values.IDictionary<T,U>is intended to work with a single value (that could, of course, be a collection).While you could, of course, have
IDictionary<T,U>implementations implement this via returning anIEnumerable<U>with a single value, this would be confusing, especially if your “U” is a collection itself (ie:List<int>). In that case, wouldILookup<T,U>.Itemreturn anIEnumerable<List<int>>, or should it do some type of check for anIEnumerable<T>value type, and then “flatten” it? Either way, it’d look confusing, and add questionable value.