Why does List<T> implement so many interfaces?

c#, derived-class

Solution

Indeed `List<T>` would have just implemented like this

public class List<T> : IList<T>, IList

It is the reflector or such decompiler shows you all the interfaces in inheritance.

Try this

public class List2<T> : IList<T>

I just compiled this and viewed in reflector, which shows like this

public class List2<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable

Problem

`List<T>` derives from the following interfaces: ``` public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable ``` I just wonder, why it needs all these interfaces (in the class declaration)? `IList` itself already derives from `ICollection<T>`, `IEnumerable<T>` und `IEnumerable`. So why is the following not enough? ``` public class List<T> : IList<T>, IList ``` I hope you can solve my confusion.

Original source

Related problems