Tuesday, 18 November 2014

Difference between Array and Arraylist in C# -.Net

Array
Array List


Arrays are strongly typed collection of same datatype
Array lists are not strongly type collection.
It will store values of same datatype
It will store values of different datatypes or same datatype
these arrays are fixed length that cannot be changed during runtime.
Array list size will increase or decrease dynamically it can take any size of values from any data type. 

Arrays belong to System.Array namespace
 Array lists will be accessible with “System.Collections” namespace
string[] arr=new string[2];
arr[0] = "text1";
arr[1] = "text2 ";

ArrayList strarr = new ArrayList();
strarr.Add("text"); // Add string values
strarr.Add(10);   // Add integer values
strarr.Add(10.05); // Add float values

No comments:

Post a Comment