SiteMap  | About    

Array and Arraylist in C#


An array stores a fixed-size sequential collection of elements of the same type. The number of dimensions and the length of each dimension are established when the array instance is created. These values can't be changed during the lifetime of the instance. Arrays are zero indexed: an array with n elements is indexed from 0 to n-1.


The ArrayList class is designed to hold heterogeneous collections of objects. However, it does not always offer the best performance. Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based. The ArrayList collection accepts null as a valid value. It also allows duplicate elements.

Array Vs ArrayList

They are different object types. Arrays belong to System.Array namespace whereas Arraylist belongs to System.Collection namespaces .

Array is strongly typed . This means that an array can store only specific type of items\elements. As a result, it is type safe, and is also the most efficient, both in terms of memory and performance. While in arraylist, we can store all the datatype values.

Array stores fixed number of elements. Size of an Array must be specified at the time of initialization . ArrayList grows automatically and you don't need to specify size. (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.