Difference Between ArrayList and Array in C#

In C#, array and ArrayList are known to be the most used data types. An array is the basic functionality of C# programming language whereas Arraylist in C# is a collection.

Both Array and ArrayList are used to store data and there is no restriction on any data type to be stored.

ArrayList vs Array in C#

The difference between the Array and ArrayList is that array stores data of the same kind of data type whereas array lists can store data of different data types.

For accessing the data from ArrayList, one needs to loop it using the object, whereas in an array you can easily access them without any object.

ArrayList vs Array in C


Comparison Table

Parameter of ComparisonArrayListArray
TypeArrayList is of non-generic typeArray is strongly typed. Only values of the same data type can be stored
Number of elementsIt is dynamic, so any number of data types can be storedOnly fix number of elements can be added
performanceIt degrades the performance since boxing and unboxing is usedIt has better performance.
NULL valueIt can accept NULL valueIt doesn’t
ClassIt uses static classIt uses namespace System.collection


What is ArrayList in C#?

Array lists are initialized using the list interface. It is considered to be one of the most flexible data in language C3. A collection in programming languages is a special class that stores the data and allows programmers to retrieve.

  1. ArrayList does not have any fixed size, the memory size is dynamic and you can change it when you want. In case, if a coder has initiated memory for 4 elements, then one can add one more element.
  2. In the array list, the size is increased with 2^n value. Also, ArrayList is non-generic, which allows us to store elements of different data types.
  3. Some of the important functions for arraylist are RemoveAt(), Remove(), Insert(), and Add().
  4. Also, it can store the null element.


                                    Using System.collection;

                                    ArrayList  a      = new ArrayList();

                                    a.add(1, “hi”);




Some of the functions that are used to interact with data stored in the arraylist.

  1. Add(): it is used to add elements in the ArrayList.
  2. insert(): it is used to insert elements at the specific index in the ArrayList.
  3. Remove(): it is used to remove a single element,
  4. RemoveAt(): it is used to remove specific elements in the ArrayList.

What is Array in C#?

Array is a data type in which a programmer can store data of the same type and fixed length. The value of length and data cannot be changed during the runtime. All the array elements are given index value and the array index being with zero.

Hence the default value is zero of the index for the first element in the array.  The syntax for declaring and defining the array in C# is the following. Since the array is a reference data type, its memory is allocated in the heap memory.

                                    Int[] array = new int[] { 10,20,30,40};

                        10   20   30   40   data

                        0     1    2     3       Indices

Some important points about arrays.

  1. Array is of fixed size and it is strongly typed. This means that, for an example, if you make an array of integer values then you can store strings.
  2. Since there is no unboxing or boxing of data, it does give better performance.

Main Differences Between ArrayList and Array in C#

  1. The size of the array is fixed and it contains the sequential collection of all the same type elements.  Whereas the array list size is not fixed and it increases with the 2^n.
  2. The dimension of the array and each dimension length is initialized when the array is created. During the runtime, it is not possible to change the value of the length of the array. For ArrayList, the value of the length of the array list can be changed dynamically.
  3. The index of the first element in array 0 and the index of the last element is n-1 where n is the length of the size of the array.
  4. ArrayList contains elements of different data types, whereas array contains data of similar data types. For example, if Array is of integer type, then only integers can be stored in the array.
  5. Array is a strongly typed data type and its efficiency is better than the ArrayList. Since in Arraylist unboxing and boxing is needed hence it is less efficient.
  6. ArrayList size increases automatically, hence you need to give any size.


  1. ArrayList Class (System.Collections) | Microsoft Docs
  2. https://www.itu.dk/research/c5/latest/ITU-TR-2006-76.pdf
Search for "Ask Any Difference" on Google. Rate this post!
[Total: 0]
One request?

I’ve put so much effort writing this blog post to provide value to you. It’ll be very helpful for me, if you consider sharing it on social media or with your friends/family. SHARING IS ♥️

Notify of
Inline Feedbacks
View all comments