Benefits of Array List
- Insert Elements: An Array List starts with a collection containing no elements. You can add them in any position as you choose them.
- Automatic Resizing: you do not need to specify the array size; as you add elements, the array automatically ensures there is enough memory for the array.
- Flexibility When Removing Elements: you can remove any element from an Array list very easily.
Limitations of Array List
The flexibility of Array List comes at a cost of performance. Since memory allocation is a very expensive business, the fixed number of elements of the simple array
makes it much faster to work with.
Example:
ArrayList obj = new ArrayList();
obj.Add(“item1”);
obj.Add(“2”);
obj.Add(“Delhi”);Obj.Insert(2,”item2″);
Obj.Remove(“item1”);
Obj.RemoveAt(3);
Tagged: Benifites of Arraylist, C# collections, System.Collections.Generic.Arraylist
Leave a Reply