How to do it: Conversions between collections

How to do it
Table of Contents
Operations
Convert from List<T> collection to array[]
How to do it
List<int> list = new List<int>();
int[] intList = list.ToArray();
Convert from List<T> collection to ArrayList
How to do it
ArrayList arrayList = new ArrayList(list);
Convert from ArrayList collection to enumerable<T>
Remarks

The “ArrayList” colletion type isn’t a generic type and therefore doesn’t implement “IEnumerable<T>”.
Nevertheless “ArrayList” implements the non generic “IEnumerable”.

How to do it
ArrayList list = new ArrayList();

list.Add(new Fruit() { Name = "Orange" });
list.Add(new Fruit() { Name = "Apple" });
list.Add(new Fruit() { Name = "Mango" });

IEnumerable fruitList = list.Cast();