ArrayList in Visual Basic
Collections are used to add/delete elements presented like and array but size may vary. So in collections size of the array get changed automatically when we add or delete any element. ArrayList is one of the simplest collections that .NET provides.
Example
Module Module1 Sub Main() Dim DynamicList As New ArrayList() DynamicList.Add("first") DynamicList.Add("Second") DynamicList.Add("Third") ' retreiving list For Each a In DynamicList Console.WriteLine(a) Next DynamicList.RemoveAt(1) ' removing element at index 1 Console.WriteLine("------------after deleting second element----------") For Each a In DynamicList Console.WriteLine(a) Next Console.ReadLine() End Sub End Module
Output
first
Second
Third
————after deleting second element———-
first
Third