VB.NET Collections

Keyword Array Collections File String Cast Class Console Data Dictionary Enum Exception For If Interface Lambda LINQ List Nothing Number Process Property Regex Select Sort Split StringBuilder Structure Sub Time Windows


Collections. A collection contains reference to other objects. We combine many class instances and values together.
We construct models,
built of objects,
that mirror real-world problems.


List. We often need to store many elements in a resizable array. We might not even know how many elements are going to be added. List here is useful.

ListSortFindBinarySearchRemove Duplicates

ArrayList. An ArrayList is an older version of the List type. It is not a generic collection. It is slower and may be harder to use. But older programs are also important.


Dictionary. If we have a large collections of elements and want to find one fast, Dictionary is an ideal solution. We perform lookups. Dictionary uses hash codes to locate elements.

DictionaryDictionary SortTryGetValue
KeyValuePair: Key and Value properties

KeyValuePair. This is a Structure. It contains a Key and a Value. These two items can have any type, but they cannot be modified once created.


Hashtable. This is an older version of the Dictionary.
It also computes hash codes
and performs lookups,
but it requires casting. Its syntax is more complex.


Types. These implement special algorithms, changing the order of insertion and removal. Some of these are generics (HashSet, Queue, Stack, Tuple).


Convert. We often need to convert collections. This requires knowledge of available functions. And sometimes custom methods are required. But many built-in methods also exist.

ToArrayToDictionaryToListArrayList to ArrayDictionary to ListList to Array
The VB.NET programming language

Collections are useful in nearly every program. The built-in collections are powerful, fast and complete. The most modern ones are found in System.Collections.Generic.