What is difference between an Array and ArrayList?
Mohan Gupta
ARRAY:-Generally we will declare arrays with fixed length.Arrays are strongly typed collection of same datatype and these arrays are fixed length that cannot be changed during run time. If we want to access values from arrays we need to pass index values.Ex. string[] arr=new string[2];arr[0]="zero";arr[1]="one";ARRAYTLIST:-Array lists are not strongly type collection. It will store values of different datatypes or same datatype. Array list size will increase or decrease dynamically it can take any size of values from any data type. These Array lists will be accessible with “System.Collections” namespace.Ex:- ArrayList objstr = new ArrayList();objstr.Add("welcome"); // Add string valuesobjstr.Add(10); // Add integer valuesobjstr.Add(10.05);// Add float values
Array: -Size is Fixed, can;t change @ runtime -It's Collectio Of Same data-types ArrayList: -Size can't be Altered @ runtime as well as design time -It's collection of different datatypes