0

This is how looks IList<T> generic interface

public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
    T this[int index] { get; set; }

    int IndexOf(T item);

    void RemoveAt(int index);
}

Why IList<T> extends both IEnumerable<T> and IEnumerable interfaces?

IEnumerable<T> already have IEnumerable. Same thing is with ICollection<T> interface.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Raskolnikov
  • 3,791
  • 9
  • 43
  • 88
  • Actually it [didn't](https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Collections/Generic/IList.cs). MSDN is just a reference info and this interfaces added only for a clarity. – Vadim Martynov Jan 12 '16 at 14:03
  • 1
    Perhaps just to make it explicit to someone looking at the declaration? – Gary McGill Jan 12 '16 at 14:04
  • Probably a typo at MSDN page: http://referencesource.microsoft.com/#mscorlib/system/collections/generic/ilist.cs – Dennis Jan 12 '16 at 14:07

1 Answers1

1

Actually it didn't. You can see actual declaration on Github:

[TypeDependencyAttribute("System.SZArrayHelper")]
#if CONTRACTS_FULL
[ContractClass(typeof(IListContract<>))]
#endif // CONTRACTS_FULL
public interface IList<T> : ICollection<T>
{
    T this[int index] {
        get;
        set;
    }

    int IndexOf(T item);
    void Insert(int index, T item);
    void RemoveAt(int index);
}

MSDN is just a reference info and this interfaces added only for a clarity.

Vadim Martynov
  • 8,602
  • 5
  • 31
  • 43
  • I prefer [MS reference source](http://referencesource.microsoft.com/#mscorlib/system/collections/generic/ilist.cs,b19f71a84062554b). – Tim Schmelter Jan 12 '16 at 14:14
  • I am actualy looking interface in visual studio .Net framework 4.6? Is here also added for clarity? – Raskolnikov Jan 12 '16 at 14:16
  • 1
    @Raskolnikov: your question was closed as [duplicate](http://stackoverflow.com/questions/4817369/why-does-does-it-really-listt-implement-all-these-interfaces-not-just-ilis) by E. Lippert himself. It's worth reading that. – Tim Schmelter Jan 12 '16 at 14:28