|
-
May 5th, 2004, 01:04 PM
#1
Thread Starter
Frenzied Member
How to sort Dictionary
Esteemed Forum Participants and Lurkers:
NEWBIE Alert!
I finally got a primitive Dictionary working, but I need a Sorted version of the Dictionary.
VB Code:
' In myModule1 - straight out of the online VB.Net help
Public Class DeviceDictionary
Inherits DictionaryBase
Default Public Property Item(ByVal key As [String]) As [String]
Get
Return CType(Dictionary(key), [String])
End Get
Set(ByVal Value As [String])
Dictionary(key) = Value
End Set
End Property
Public ReadOnly Property Keys() As ICollection
Get
Return Dictionary.Keys
End Get
End Property
Public ReadOnly Property Values() As ICollection
Get
Return Dictionary.Values
End Get
End Property
Public Sub Add(ByVal key As [String], ByVal value As [String])
Dictionary.Add(key, value)
End Sub 'Add
Public Function Contains(ByVal key As [String]) As Boolean
Return Dictionary.Contains(key)
End Function 'Contains
Public Sub Remove(ByVal key As [String])
Dictionary.Remove(key)
End Sub 'Remove
End Class
' My Code ---
Public g_devlist As New DeviceDictionary
Dim myDE as DictionaryEntry
....
' Iterate through the DeviceDictionary
For Each myDE in g_devlist
' Do my thing, but I need it in SORTED order!
Next
This works great, except that I need to iterate through the Dictionary in SORTED order by key, and the default doesn't seem to do that. I couldn't find any ".Sort" help at all for Dictionary stuff.
My sincere appreciation for any comments, suggestions, or assistance.
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|