Get or set the number of elements that the ArrayList can contain in CSharp
Description
The following code shows how to get or set the number of elements that the ArrayList can contain.
Example
//w ww . j a va 2 s . c o m
using System;
using System.Collections;
class MainClass {
public static void Main() {
ArrayList al = new ArrayList();
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("Current capacity: " + al.Capacity);
}
}
The code above generates the following result.