ArrayList.Remove removes the first occurrence of a specific object from the ArrayList.
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesArrayList
Public Shared Sub Main()
Dim myAL As New ArrayList()
myAL.Add("A")
myAL.Add("B")
myAL.Add("C")
myAL.Add("D")
myAL.Add("B")
myAL.Add("C")
myAL.Add("D")
myAL.Add("B")
myAL.Add("C")
myAL.Add("D")
PrintValues(myAL)
myAL.Remove("B")
PrintValues(myAL)
myAL.RemoveAt(5)
PrintValues(myAL)
myAL.RemoveRange(4, 3)
PrintValues(myAL)
End Sub
Public Shared Sub PrintValues(myList As IEnumerable)
Dim obj As [Object]
For Each obj In myList
Console.Write(" {0}", obj)
Next obj
Console.WriteLine()
End Sub
End Class
Related examples in the same category