C# ArrayList Example
The ArrayList is similar to the C# array data type. The greatest difference is the dynamic nature of the collection of array list.
- The add method is used to add an element to the ArrayList.
ArrayList Example:
ArrayList arrayList = new ArrayList();
arrayList.Add("Element 1");
arrayList.Add("Element 2");
arrayList.Add("Element 3");
Console.WriteLine("ArrayList Count: " + arrayList.Count);
Console.WriteLine("Contains Element2: " + arrayList.Contains("Element 2"));
arrayList.Remove("Element 2");
Console.WriteLine("ArrayList Count: " + arrayList.Count);

Pingback: C# Collections Tutorial | C# Examples