July 2015
Intermediate to advanced
1300 pages
87h 27m
English
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. You can rewrite the code shown in the section about the Dictionary(Of TKey, TValue) collection as follows:
Dim peopleDictionary As New SortedDictionary(Of String, Integer)peopleDictionary.Add("Alessandro", 37)peopleDictionary.Add("Stephen", 27)peopleDictionary.Add("Rod", 44)For Each item As KeyValuePair(Of String, Integer) In peopleDictionary Console.WriteLine(item.Key & " of age " & item.Value.ToString)Next
This code will produce the following result:
Alessandro of age 37 ...
Read now
Unlock full access