Difference between arraylist and list: -
- Arrays are fixed in size while Arraylist is resizable.
- Arrays are strongly typed, in other words when you create an array it can store only one data type data. Arraylist can store any datatype.
Array list takes any data type which leads to boxing and unboxing. As arrays are strongly typed they do not do boxing and unboxing. So arrays are faster as compared to array list.
// Array definition
int str = new int;
// Array list definition
ArrayList MyList = new ArrayList();
Generic equivalent for array list, stack, queues and hashtable: -
- Array list generic equivalent is List<int>.
- Stack generic equivalent is Stack<int>.
- Queue generic equivalent is Queue<int>.
- Hashtable generic equivalent is Dictionary<int,int>.