< Day Day Up > |
The Collection object stores lists of objects. Objects in a collection can be assigned an optional key value and can be retrieved either by position (like an array) or by key (like a dictionary). Unlike the collection objects such as ArrayList and HashTable in System.Collections , values can be removed from a Collection object while the collection is being enumerated. When a value is removed from a Collection , all enumerators are automatically updated.
Public Sub New() This constructor creates a new, empty collection object. Public Sub Add(ByVal Item As Object, _ Optional ByVal Key As String = Nothing, _ Optional ByVal Before As Object = Nothing, _ Optional ByVal After As Object = Nothing) The Add method adds a new value to the collection, with an optional key specified by the Key parameter. The item can be inserted before or after an item with a particular key by supplying the Before or After parameters; Before and After cannot both be specified at the same time. Public Sub Remove(ByVal Index As Integer) Public Sub Remove(ByVal Key As String) The Remove method removes a value from the collection either by index or by key. The Collection type allows removing methods while the collection is being iterated, unlike other collection types, such as ArrayList . Public Property Count() As Integer The read-only Count property returns the number of items stored in the collection. Public ReadOnly Default Property Item(ByVal Index As Integer) As Object Public ReadOnly Default Property Item(ByVal Key As String) As Object The Item property allows fetching a particular item from the collection by index or by key. |
< Day Day Up > |