We help IT Professionals succeed at work.

"peeking" into a sorted dictionary (vb.net)

larrysy used Ask the Experts™
Is there a way to "peek" into a sorted dictionary in the same way as the queue collection?  I don't know the value of the keys, but I want to check the item with the smallest key.  Or, is there another way.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
See the SortedDictionary.Values() property:

    "The values in the SortedDictionary(TKey, TValue).ValueCollection are sorted according to the Comparer property, and are in the same order as the associated keys in the SortedDictionary(TKey, TValue).KeyCollection returned by the Keys property."

So you can just do:

        Dim sd As New SortedDictionary(Of String, Integer)


Thanks,  I don't know if the sorted dictionary is the best solution for my problem but I'll ask it in another question.