IEnumerable is an interface that allows iteration through a set of elements (for example, through the foreach keyword).
The array is inline .NET. It contains elements of the same type but has a fixed size. When you create an array with x elements, it cannot grow or shrink.
IList defines an interface for a list, and also implements IEnumerable.
The list implements the IList interface; This is a specific type of list.
The difference between .NET lists and arrays is that elements that they grow to be large enough to contain all the necessary elements can be added to the lists. The list stores this internally in the array and when the array is no longer large enough to hold all the elements, a new array is created and the elements copied to.
IList and arrays implement IEnumerable. The way interfaces work - classes implement the contract and behave in a similar way and can be considered similarly as a result (you know that the class implements IEnumerable, you do not need to know how or whys). I suggest you familiarize yourself with interfaces, etc.
Mark Simpson Apr 19 '09 at 3:03 2009-04-19 03:03
source share