Reputation: 10539
From mscorlib.dll:
public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{..}
public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>
{...}
Why List<T>
have to explicitly derived from ICollection<T>, IEnumerable<T>, IEnumerable,
in addition of derived from IList<T>
which itself derived from ICollection<T>, IEnumerable<T>, IEnumerable
?
Upvotes: 2
Views: 131
Reputation: 32760
The object browser or Reflector or similar don't have the source code, they have metadata to work with. Its not easy to know inspecting that information if a type implements directly an interface or not, so the easy option, because the ultimate goal is documentation, is to simply show all interfaces even if some are redundant.
For more information, read this.
Upvotes: 3
Reputation:
Don't trust decompiled code to be an accurate representation of the original source code.
The original source code contains only
public class List<T> : IList<T>, System.Collections.IList, IReadOnlyList<T>
So yes, you're right that List<T>
doesn't need to be explicitly derived from ICollection<T>
and others. It isn't.
Upvotes: 5