June 2003
Intermediate to advanced
800 pages
34h 20m
English
You need to enumerate over the contents of a Hashtable.
Use the DictionaryEntry type with a For/Each block.
With a generic collection, you perform enumeration using the type in the collection (or one of its base types). The Hashtable does not support this convention. Instead, you must iterate over a collection of DictionaryEntry objects.
There is one DictionaryEntry object for each item stored in the collection. You can retrieve the key for the item from the DictionaryEntry.Key property, and you can retrieve the item in the collection from the DictionaryEntry.Value property.
The following code demonstrates this technique on a collection that contains strings:
' Create the collection and add two ...
Read now
Unlock full access