Array vs ArrayList

In yet another round of fight, today we have contenders Array and ArrayList:

ARRAY ARRAYLIST
1. Array can store single data like Char[] vowel=new Char[]; Array list you can store multiple datatypes and inserting and removing element is easy.

ArrayList a_list=new ArrayList();

2. Array is in the System namespace ArrayList is in the System.Collections namespace.
3. The capacity of an Array is fixed. ArrayList can increase and decrease size dynamically

Ex:

ArrayList list = new ArrayList();

list.Add(“One”);

list.Add(“Two”);

list.Add(“Three”);

ARRAY

ARRAYLIST

1.

Array can store single data like Char[] vowel=new Char[];

Array list you can store multiple datatypes and inserting and removing element is easy.

ArrayList a_list=new ArrayList();

2.

Array is in the System namespace

ArrayList is in the System.Collections namespace.

3.

The capacity of an Array is fixed.

ArrayList can increase and decrease size dynamically

Ex:

        ArrayList list = new ArrayList();
        list.Add("One");
        list.Add("Two");
        list.Add("Three");

Leave a comment

Filed under C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s