Retrieving From Hashtables

Question regarding Hashtables...
I've noticed that when retrieving records from a hashtable, they do not come out in the same order as they were added. I then tried a simple example to see how the records are being retrieved. My code is as follows....

Dim h As New Hashtable()
Dim eh As IDictionaryEnumerator = h.GetEnumerator
Dim s As String

h.Add("d", "Jessica")
h.Add("c", "Chris")
h.Add("b", "Frank")

While eh.MoveNext
s &= eh.Value & " " & eh.Key & " "
End While

The names end up being retrieved as Jessica, Frank, Chris.
Can anyone point out what I may be doing wrong or suggest how I can retrieve the items in the same order they were inserted?

Much thanks in advance,


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!