Remove an Item from ArrayList in VB.NET

This blog defines function Remove and RemoveAt in VB.NET.

ArrayList

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

Remove : The Remove function is used to remove an Item from ArrayList.

RemoveAt: The RemoveAt function is used to remove an item from a specified position.

For example

Module Module1

    Sub Main()

        Dim i As Integer

        Dim ItemList As New ArrayList()

        ItemList.Add("G")

        ItemList.Add("H")

        ItemList.Add("I")

        ItemList.Add("J")

        ItemList.Add("K")

        Console.WriteLine("Shows Added Items")

        For i = 0 To ItemList.Count - 1

              Console.WriteLine(ItemList.Item(i))

        Next

        ItemList.Remove("G")

        ItemList.RemoveAt(3)

        Console.WriteLine("After remove Items in the ArrayList")

        For i = 0 To ItemList.Count - 1

            Console.WriteLine(ItemList.Item(i))

        Next

    End Sub

End Module

 

OUTPUT

 

arraylist.gif