The Dictionary(Of TKey, TValue) Collection

The System.Collections.Generic.Dictionary(Of TKey, TValue) collection is the generic counterpart for the HashTable. Each item within a Dictionary is a key/value pair; therefore, the constructor requires two arguments (TKey and TValue) where the first one is the key and the second one is the value. The following code shows instantiating a Dictionary(Of String, Integer) in which the String argument contains a person’s name and the Integer argument contains the person’s age:

image

A single item in the collection is of type KeyValuePair(Of TKey, TValue) and both arguments reflect the collection’s ones. For a better ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.