difference between array and array list in c#

1.The capacity of an Array is fixed. 
Where as, 
ArrayList can increase and decrease size dynamically.
 
2.An 
Array is a collection of similar items. 
Where as, 
ArrayList can hold item of different types.
 
3.Array is in the System namespace. 
Where as, ArrayList is in the System.Collections namespace.
 
4.An 
Array can have multiple dimensions. 
Where as, 
ArrayList always has exactly one dimension.
 
We can set the lower bound of an 
Array
Where as, the lower bound of an 
ArrayList is always zero.
 
 
Array is faster and that is because ArrayList uses a fixed amount of array. 
However when you add an element to the 
ArrayList and it overflows. It creates a new Array and copies every element from the old one to the new one. 
You will only feel this if you add to often.

Comments

Popular posts from this blog

data annotation attributes c#

how to create windows service setup in c#.net

difference between var and dynamic c#