August 2012
Intermediate to advanced
840 pages
22h 41m
English
The Visual Basic collection classes basically hold items and don’t provide a lot of extra functionality. Other classes described later in this chapter provide more features.
The following sections describe the simple collection classes in Visual Basic: ArrayList, StringCollection, and NameValueCollection. They also describe strongly typed collections that you can build to make code that uses these classes a bit easier to debug and maintain.
The ArrayList class is a resizable array. You can add and remove items from any position in the list and it resizes itself accordingly. The following table describes some of the class’s more useful properties and methods.
| PROPERTY/METHOD | PURPOSE |
| Add | Adds an item at the end of the list. |
| AddRange | Adds the items in an object implementing the ICollection interface to the end of the list. |
| BinarySearch | Returns the index of an item in the list. The items must implement the IComparable interface, or you must provide the Sort method with an IComparer object. |
| Capacity | Gets or sets the number of items that the list can hold. |
| Clear | Removes all of the items from the list. |
| Contains | Returns True if a specified item is in the list. |
| CopyTo | Copies some of the list or the entire list into a one-dimensional Array object. |
| Count | Returns the number of items currently in the list. This is always less than or equal to Capacity. |
| GetRange | Returns an ArrayList containing the items in part of the list. |
| IndexOf | Returns the zero-based ... |
Read now
Unlock full access