Overview
- Resizable, unsorted, index-based collection.
- Suffers from boxing/unboxing when working with value types.
- Implements IEnumerable, allowing foreach operations.
- The IEnumerator is a .NET implementation of the Iterator Pattern.
Good practice
- When possible, use a generic collection instead of the object-based ArrayList.
Examples
Adding and Removing Elements
ArrayList a = new ArrayList();
a.Add(16);
a.AddRange(new object[] { "Hello", "World" });
a.Insert(0, "Start");
a.InsertRange(2, new int[] { 32, 64 });
foreach (object o in a) { Console.WriteLine(o); }
a.Remove("Hello");
a.RemoveAt(1);
a.RemoveRange(1, 2);
foreach (object o in a) { Console.WriteLine(o); }
Checking Existence
ArrayList a = new ArrayList();
a.AddRange(new object[] { "Hello", "World" });
Console.WriteLine(a.Contains("World") ? "World Found" : "World Missing");
You May Also Like

Exam 70-536 Study Notes
My study notes for Microsoft exam 70-536: .NET types, collections, generics, I/O, serialization and more, with C# examples.

Starting Exam 70-536 Study
After a burnout, I'm putting my own project on hold to study for Microsoft exam 70-536.

Design Patterns - Proxy Pattern
The Proxy Pattern, and the last article in the design patterns series, now that I've finished reading Head First Design Patterns.




