Example

using System;
using System.Collections;

namespace Samples
{
  public class ArrayListSamples
  {
    public static void Main() 
    {
      ArrayList a = new ArrayList();
      a.Add("damien");
      a.Add(42);
      a.Add(new object());
      Console.WriteLine("-- ArrayList --" );
      Console.WriteLine("Count: {0}", a.Count);
      Console.WriteLine("Capacity: {0}", a.Capacity );
      Console.Write("Values:");
      PrintElements(a);
      a.Reverse();
      Console.Write("Values:");
      PrintElements(a);
      a.Remove(new object());
      a.Remove("damien");
      Console.Write("Values:");
      PrintElements(a);
    }
    public static void PrintElements(IEnumerable ie) 
    {
      IEnumerator e = ie.GetEnumerator();
      while(e.MoveNext())
        Console.Write(" {0}", e.Current );
      Console.WriteLine();
    }
  }
}
The output is
 -- ArrayList -- Count: 3 Capacity: 16 ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.