Public Overridable Function GetRange (index As Integer, count As Integer ) As ArrayList
返回一个ArrayList,它表示源ArrayList中元素的子集。
Public Overridable Function IndexOf (value As Object) As Integer
返回ArrayList或其一部分中第一次出现的值的从零开始的索引。
Public Overridable Sub Insert (index As Integer, value As Object)
将元素插入到ArrayList中的指定索引处。
Public Overridable Sub InsertRange (index As Integer, c As ICollection)
将集合的元素插入ArrayList中的指定索引处。
Public Overridable Sub Remove (obj As Object )
从ArrayList中删除第一次出现的特定对象。
Public Overridable Sub RemoveAt (index As Integer)
移除ArrayList指定索引处的元素。
Public Overridable Sub RemoveRange (index As Integer, count As Integer)
从ArrayList中删除一系列元素。
Public Overridable Sub Reverse
反转ArrayList中元素的顺序。
Public Overridable Sub SetRange (index As Integer, c As ICollection )
在ArrayList中的一系列元素上复制集合的元素。
Public Overridable Sub Sort
对ArrayList中的元素进行排序。
Public Overridable Sub TrimToSize
将容量设置为ArrayList中元素的实际数量。
Dim al As ArrayList = New ArrayList()
Dim i As Integer
Console.WriteLine("Adding some numbers:")
al.Add(45)
al.Add(78)
al.Add(33)
al.Add(56)
al.Add(12)
al.Add(23)
al.Add(9)
Console.WriteLine("Capacity: {0} ", al.Capacity)
Console.WriteLine("Count: {0}", al.Count)
Console.Write("Content: ")
For Each i In al
Console.Write("{0} ", i)
Next i
Console.WriteLine()
Console.Write("Sorted Content: ")
al.Sort()
For Each i In al
Console.Write("{0} ", i)
Next i
Console.WriteLine()
Console.ReadKey()
End Sub
End Module
编译并执行上述代码后,将产生以下结果-
Adding some numbers:
Capacity: 8
Count: 7
Content: 45 78 33 56 12 23 9
Sorted Content: 9 12 23 33 45 56 78