Create an ArrayList that is empty and has the specified initial capacity in CSharp

Description

The following code shows how to create an ArrayList that is empty and has the specified initial capacity.

Example


using System;//from   www  .j a  va2 s .  c  o  m
using System.Collections;

class Class1
{
  static void Main(string[] args)
  {
       ArrayList al2 = new ArrayList( 10 );
       Console.WriteLine(al2.Count);
       Console.WriteLine(al2.Capacity);

    }
}

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