Get the number of elements actually contained in the ArrayList in CSharp
Description
The following code shows how to get the number of elements actually contained in the ArrayList.
Example
/* w w w . jav a 2 s . co m*/
using System;
using System.Collections;
class MainClass {
public static void Main() {
ArrayList al = new ArrayList();
Console.WriteLine("Initial number of elements: " + al.Count);
Console.WriteLine("Adding 6 elements");
al.Add('C');
al.Add('A');
al.Add('E');
al.Add('B');
al.Add('D');
al.Add('F');
Console.WriteLine("Number of elements: " + al.Count);
}
}
The code above generates the following result.