ArrayList in VB.NET

This blog defines the ArrayList and it's important function in VB.NET.

ArrayList

Array List contains a simple list of values. ArrayList is the part of data structure. ArrayList contains a simple list of values and very easily we can add , insert , delete , view etc.. to do with ArrayList. It is the part of System.Collection.

Important function of the ArrayList

Add : Add an Item in an ArrayList.

Insert : Insert an Item in a specified position in an ArrayList.

Remove : Remove an Item from ArrayList.

RemoveAt: Remove an item from a specified position.

Sort : Sort Items in an ArrayList.

For example

Module Module1

    Sub Main()

        Dim i As Integer

        Dim ItemList As New ArrayList()

        ItemList.Add("A")

        ItemList.Add("B")

        ItemList.Add("C")

        ItemList.Add("D")

        ItemList.Add("E")

        Console.WriteLine("Shows Added Items")

        For i = 0 To ItemList.Count - 1

            Console.WriteLine(ItemList.Item(i))

        Next

        ItemList.Insert(3, "F")

        ItemList.Sort()

        ItemList.Remove("A")

        ItemList.RemoveAt(3)

        Console.WriteLine("final Items in the ArrayList")

        For i = 0 To ItemList.Count - 1

            Console.WriteLine(ItemList.Item(i))

        Next

    End Sub

End Module

OUTPUT

a1.gif