C# ArrayList Examples, Usage and Tips
You need to use the ArrayList class in an older C# program to fix or improve the dynamic arrays. ArrayList is still useful, even when newer classes are more durable and popular. Here we see examples and tips using the ArrayList class in the C# programming language, moving from the simpler tasks to the more advanced usages of ArrayList.
Add elements
The Add method on ArrayList is used in almost every program. It appends a new element object to the very end of the ArrayList. You can keep adding elements to your collection until memory runs out. The objects are stored in the managed heap.
Program that uses ArrayList [C#]
using System.Collections;
class Program
{
static void Main()
{
//
// Create an ArrayList and add three elements.
//
ArrayList list = new ArrayList();