December 2001
Beginner
976 pages
22h 4m
English
The ArrayList is a collection class that models a dynamic array, whose size increases as required when new objects are added to the array. The items in the array are Object instances, which means that you can use instances of this class to hold any type of variable.
The ArrayList implements the IList, ICollection, and ICloneable interfaces. Let's look first at a simple example of how to use it:
Sub Main()
Dim a As ArrayList = New ArrayList()
a.Add("Joe")
a.Add("Jane")
a.Add("Jim")
Dim i As Integer
For i = 0 To a.Count - 1
Console.Out.WriteLine(a.Item(i))
Next
End Sub
First you create the ArrayList a using the regular object variable declaration and initialization. Then you use the Add method (from IList) to add three literal strings ...
Read now
Unlock full access