C# ArrayList ArrayList(Int32)
Description
ArrayList ArrayList(Int32)
initializes a new instance
of the ArrayList class that is empty and has the specified initial capacity.
Syntax
ArrayList.ArrayList(Int32)
has the following syntax.
public ArrayList(
int capacity
)
Parameters
ArrayList.ArrayList(Int32)
has the following parameters.
capacity
- The number of elements that the new list can initially store.
Example
The following code demonstrates the 3 constructors of ArrayList.
using System;//www. ja v a 2 s.c o m
using System.Collections;
class Class1
{
static void Main(string[] args)
{
ArrayList al1 = new ArrayList();
ArrayList al2 = new ArrayList( 10 );
int[] intArr = new int[10];
ArrayList al3 = new ArrayList( intArr );
ArrayList myArrayList = new ArrayList();
myArrayList.Capacity = 10;
}
}
The code above generates the following result.