ArrayList.GetRange returns an ArrayList which represents a subset of the elements in the source ArrayList.
Imports System
Imports System.Collections
Public Class SamplesArrayList
Public Shared Sub Main()
Dim myAL As New ArrayList()
myAL.Add("The")
myAL.Add("quick")
myAL.Add("brown")
Dim mySourceList As New Queue()
mySourceList.Enqueue("A")
mySourceList.Enqueue("B")
mySourceList.Enqueue("C")
Dim mySubAL As ArrayList = myAL.GetRange(0, 5)
PrintValues(mySubAL, vbTab)
myAL.SetRange(1, mySourceList)
mySubAL = myAL.GetRange(0, 5)
PrintValues(mySubAL, vbTab)
End Sub
Public Shared Sub PrintValues(myList As IEnumerable, mySeparator As Char)
Dim obj As [Object]
For Each obj In myList
Console.Write("{0}{1}", mySeparator, obj)
Next obj
Console.WriteLine()
End Sub
End Class
Related examples in the same category