Remove all elements from the ArrayList in CSharp

Description

The following code shows how to remove all elements from the ArrayList.

Example


using System;/*from  w  ww  .j ava2s.c om*/
using System.Collections;

class MainClass
{
  static void Main(string[] args)
  {
    ArrayList a = new ArrayList(10);
    a.Add("a");
    a.Add("a");
    a.Add("a");
    a.Add("a");

        Console.WriteLine(a.Count);

    a.Clear();
    
    Console.WriteLine(a.Count);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary