Reputation: 1737
I was looking at the metadata generated for IDictionary<TKey, TValue>
interface and I noticed it implements
public interface IDictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
Isn't this redundant? Looking at the metadata of ICollection<T>
it shows that it already implements IEnumerable<T>, IEnumerable
And why does IEnumerable<T>
implments IEnumerable
, while ICollection<T>
doesn't implement ICollection
?
Upvotes: 3
Views: 201
Reputation: 32780
Read this. It explains everything you want to know about your first question.
I quote the most relevant part:
Why do tools like Reflector or the object browser show the whole list?
Those tools do not have the source code. They only have metadata to work from. Since putting in the full list is optional, the tool has no idea whether the original source code contains the full list or not. It is better to err on the side of more information. Again, the tool is attempting to help you by showing you more information rather than hiding information you might need.
Upvotes: 0
Reputation: 13684
The metadata show all implemented interfaces, especially those obtained through inheritance. If you look into the reference source of IDictionary<TKey, TValue>
, you see that the actual implementation only implements ICollection<KeyValuePair<TKey, TValue>>
:
public interface IDictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>
Upvotes: 4