Frequently Asked Interview Questions

Difference Between ArrayList and Array in C#

Array Vs ArrayList
Array:
1. The size of an Array is fixed.
2. An Array is a collection of similar items (of the same type).
3. An Array can have multiple dimensions.
4.Array is in the System namespace.
5. Syntax:

    int[] subject = new int[10];

ArrayList:
1. ArrayList can increase and decrease size dynamically.The capacity of a ArrayList is the number of elements that the ArrayList can hold. As elements are added to a ArrayList, the capacity is automatically increased as required by reallocating the internal array.
The default ArrayList size is 16.
2. ArrayList can hold item of different types.
3. ArrayList always has exactly one dimension.
4. ArrayList is in the System.Collections namespace.
5. Syntax:

    ArrayList array_list = new ArrayList() // No initial size specified, the default capacity of ArrayList is: 16
    ArrayList array_list = new ArrayList(10) // Size 10

Most Visited Pages

Home | Site Index | Contact Us