IEnumerable, ICollection, IList and List

Posted on Updated on

IEnumerable, ICollection, IList and List

As a matter of first importance, it is essential to comprehend, that there are two distinct interfaces characterized in the .NET base class library. There is a non-bland IEnumerable interface and there is a non specific sort safe IEnumerable<T> interface.

The IEnumerable interface is situated in the System. Collections namespace and contains just a solitary technique definition.

The interface definition resembles this:

public interface IEnumerable


    IEnumerator GetEnumerator();


The GetEnumerator strategy must give back an occasion of an object of a class which executes the IEnumerator interface. We won’t observe the meaning of the IEnumerator interface this time, however in the event that you are intrigued, please visit the authority msdn documentation.

Know that the C# dialect foreach catchphrase works with assorted types that execute the IEnumerable interface. Just in C# it likewise works with things that don’t explicitly actualize IEnumerable or IEnumerable<T>. I trust you have been utilizing the foreach watchword ordinarily and without agonizing over the motivation behind why and how it functioned with that sort.


We should now investigate the meaning of the nonexclusive and sort safe rendition called IEnumerable<T> which is situated in the System.

Collections.Generic namespace:

public interface IEnumerable<out T> : IEnumerable


    IEnumerator<T> GetEnumerator();


As should be obvious the IEnumerable<T> interface acquires from the IEnumerable interface. In this manner a sort which actualizes IEnumerable<T> has likewise to execute the individuals from IEnumerable. IEnumerable<T> characterizes a solitary strategy GetEnumerator which gives back an occurrence of an article that executes the IEnumerator<T> interface.


How about we now investigate the meaning of the non specific and sort safe adaptation called

IEnumerable<T> which is situated in the System.Collections.Generic namespace:

public interface IEnumerable<out T> : IEnumerable


    IEnumerator<T> GetEnumerator();


IEnumerable<T> characterizes a solitary system GetEnumerator which gives back an occasion of an item that actualizes the IEnumerator<T> interface. We won’t observe this interface this time.


There are additionally two variants of ICollection which are System.Collections.ICollection and the non specific adaptation System.Collections.Generic.ICollection<T>.

public interface ICollection : IEnumerable


    int Count { get; }

    bool IsSynchronized { get; }

    Object SyncRoot { get; }

    void CopyTo(Array array, int index);


ICollection acquires from IEnumerable. You in this way have all individuals from the IEnumerable interface executed in all classes that actualize the ICollection interface.


public interface ICollection<T> : IEnumerable<T>, IEnumerable


    int Count { get; }

    bool IsReadOnly { get; }

    void Add(T item);

    void Clear();

    bool Contains(T item);

    void CopyTo(T[] array, int arrayIndex);

    bool Remove(T item);


reality, we have some more systems to include, uproot and clear an accumulation. The way synchronization was executed varies too. I trust this happened on the grounds that the non specific adaptation of this interface was presented with .NET 2.0 while the non-bland rendition was at that point presented in .NET 1.1.


public interface IList : ICollection, IEnumerable


    bool IsFixedSize { get; }

    bool IsReadOnly { get; }

    Object this[int index] { get; set; }

    int Add(Object value);

    void Clear();

    bool Contains(Object value);

    int IndexOf(Object value);

    void Insert(int index, Object value);

    void Remove(Object value);

    void RemoveAt(int index);


IList executes ICollection and IEnumerable. Moreover it gives technique definitions to adding and uprooting components and to clear the accumulation. It additionally gives systems to taking care of the situating of the components inside of the gathering.


For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666

Please fill the form and we shall contact you soon.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s