C# Collections Introduction


The general meaning of a collection is simply a group of things of the same type. It could be a stamp or coin collection for example. In programming we could have a group of a primitive types such as a group integers in an array.

Arrays in C# are implemented as instances of the System.Array class and are just one type of collection classes, which maintain lists of objects. Several interfaces in the System.Collections namespace provide basic collection functionality: IEnumerable, ICollection, IList, and IDictionary. The System.Array implements IEnumerable, ICollection and IList but it doesn’t support some of the more advanced features of IList and it represents a list of items using a fixed size.

One of the classes in the System.Collections namespace, System.Collections.ArrayList also implements IList, ICollection and IEnumerable but it does so in a more sophisticated way than System.Array. Here you can use variable-length lists of items.