June 2003
Intermediate to advanced
800 pages
34h 20m
English
You need to copy items from an array into an ArrayList.
You can add an entire range of items into an ArrayList quickly using the AddRange method.
The ArrayList.AddRange method accepts any object that implements the ICollection interface (including an array or another ArrayList), and copies all the items it contains into the ArrayList.
Dim Colors() As String = {"blue", "green", "pink", "yellow"}
' Copy the strings in the Colors array into the List ArrayList.
Dim List As New ArrayList()
List.AddRange(Colors)
' Display the contents of the ArrayList.
Dim Item As String
For Each Item In List
Console.WriteLine(Item)
NextKeep in mind that if you are using a reference type, when you copy it into the ...
Read now
Unlock full access