List-related interfaces
While developing applications in C#, you frequently use various collections, including lists. For this reason, it is worth mentioning three common interfaces:
IEnumerableICollectionIList
The order of them is important because IEnumerable is the base interface for ICollection and IList, while ICollection is the base interface for IList. However, what is inside such interfaces? Let’s take a look!
IEnumerable only provides you with a simple iteration over a collection. For this reason, it exposes the GetEnumerator method.
The ICollection interface adds the following methods for manipulating the collection:
Addadds a given item to the collectionClearremoves all the items from the collectionContainschecks whether a given item exists in the collectionRemoveremoves the first occurrence of a given item from the collection
It also exposes the Count and IsReadOnly properties, as well as the CopyTo...