The SortedDictionary(Of TKey, TValue) Collection

The System.Collections.Generic.SortedDictionary(Of TKey, TValue) works exactly like the Dictionary collection except that items are automatically sorted each time you perform a modification. We can rewrite the code shown in the section about the Dictionary(Of TKey, TValue) collection as follows:

image

This code will produce the following result:

image

Notice how the result has a different order than the one we added items to the collection with. In fact, items are sorted alphabetically. This collection performs ...

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.