Thursday, 19 June 2014

what is difference between arraylist and list

ArrayList
it is a non generic collection
it is present in System.Collections name space
it does not have type restriction for storing data
it is not Type Safe
example
ArrayList arrList = new ArrayList();
arrList.Add(921);
arrList.Add("Mudassar Khan");
arrList.Add(DateTime.Now);

List
it is a generic collection
it is present in System.Collections.Generic name space
it  have type restriction for storing data
it is  Type Safe
example
List<string> lstString = new List<string>();
lstString.Add("Mudassar Khan");
lstString.Add("Robert Hammond");
lstString.Add("Ramesh Singh");

No comments:

Post a Comment