C# ArrayList ArrayList(ICollection)

Description

ArrayList ArrayList(ICollection) initializes a new instance of the ArrayList class that contains elements copied from the specified collection and that has the same initial capacity as the number of elements copied.

Syntax

ArrayList.ArrayList(ICollection) has the following syntax.


public ArrayList(
  ICollection c
)

Parameters

ArrayList.ArrayList(ICollection) has the following parameters.

  • c - The ICollection whose elements are copied to the new list.

Example

The following code demonstrates the 3 constructors of ArrayList.


using System;/*w w  w . j a  va  2 s. co 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.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack