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.
5) We can set the lower bound of an Array. Where as, The lower bound of an ArrayList is always zero.
Please check the following example:
ArrayList al = new ArrayList();
al.Add("1");
al.Add(2);
al.Add(new DateTime(2001, 4, 2));
foreach (object o in al)
{
Response.Write(o.ToString() + "
");
}
No comments:
Post a Comment