ArrayList
An ArrayList provides array-like access, using indexers, while having the capability to grow dynamically as needed. The collection maintains the order in which items were added and provides the ability to insert and remove items. The following are typical operations:
var lst = new ArrayList();lst.Add(1); // { 1 }lst.AddRange(new[] { 2, 3, 7, 6, 5, 4 }); // { 1, 2, 3, 7, 6, 5, 4 }lst.Insert(index: 0, value: 0); // { 0, 1, 2, 3, 7, 6, 5, 4 }lst.RemoveAt(index: 4); // { 0, 1, 2, 3, 6, 5, 4 }lst.Remove(obj: 1); // { 0, 2, 3, 6, 5, 4 }lst.RemoveRange(index: 2, count: 3); // { 0, 2, 4 }lst.Reverse(); // ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access