ArrayList.Clear removes all elements 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("E")
Console.WriteLine(myAL.Count)
Console.WriteLine(myAL.Capacity)
PrintValues(myAL)
myAL.Clear()
Console.WriteLine("After Clear,")
Console.WriteLine(" Count : {0}", myAL.Count)
Console.WriteLine(" Capacity : {0}", myAL.Capacity)
Console.Write(" Values:")
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 'PrintValues
End Class
Related examples in the same category