Introduction
Interfaces

- Class diagram is not having all the methods but contains an important method that belongs to each collection interface.
- Collection interface is available in both generic and non-generic form, so in the diagram, obj type is the object in nongeneric form and obj type is T(template type) in generic form.
| Functionality Provided | Read | Count | Add & Remove |
Index-Based Read | Index-Based Add & Remove | |
| IEnumerable | 1. Provide Read-only Collection. |
Y | N | N | N | N |
| ICollection | 1. Allow modifying collection. |
Y (Inherited) |
Y | Y | N | N |
| IReadOnlyCollection | 1. Allow reading collection. |
Y (Inherited) |
Y | N | N | N |
| IList | 1. Allows accessing collection by Index. |
Y (Inherited) |
Y
(Inherited)
|
Y
(Inherited)
|
Y | Y |
| IReadOnlyList |
1. Allow reading collection by Index.
|
Y (Inherited) |
Y
(Inherited)
|
N | N | Y |
Note:
In the above diagram (Inherited), the columns indicate that the features are inherited from the parent, and to find out from which parent one must look in the interface collection diagram.
So from the above table, three main interfaces functionality concluded in the following way:
- IEnumerable – interface provides minimum functionality which is Enumration.
- ICollection – interface provides medium functionality which is getting size, adding, removing, and clearing collection i.e. modification of collection. As it inherited from IEnumerable so includes the functionality of IEnumerable. IList – interface provides full functionality which is index base accessing of collection element, index base adding, index base removing from the collection. As it inherited from ICollection it includes the functionality of Enumerable and ICollection.
The following are some important things to know:
- IEnumerable interface under the hood makes use of IEnumerator for providing read-only and forward mode read.
- IReadOnly*** and IEnumerable are used for providing read-only collections. But the difference is that IEnumerable allows the collection to read in a forward-only mode where IReadOnly*** provides the feature of Collection /List but only in read-only mode i.e. without modification feature like add & remove.
- IReadOnly is part of the collection interface from framework 4.5.
Above table list down the features provided by each interface when the collection gets converted to interface type or class implement interface to provide the feature of the collection.
It’s very important for developers to understand these interfaces because the rule says it's always good to depend on the interface rather than on the concrete type.

Ramzanali MominPosted Sep 6, 2018, 11:55 PM
Thanks a lot
Humayun Kabir MamunPosted Sep 11, 2015, 2:41 AM
Nice...
Santhakumar MunuswamyPosted Sep 7, 2015, 2:31 PM
Thanks for nice share
Mohammed IbrahimPosted Sep 7, 2015, 11:52 AM
nice information
Pankaj Kumar ChoudharyPosted Sep 7, 2015, 9:01 AM
Short but More efficient article Sir.......
Rajeesh MenothPosted Sep 7, 2015, 5:16 AM
Nice Share Sir..
Karthikeyan KPosted Sep 7, 2015, 4:21 AM
Good one sir...Thanks for sharing