c# - Reverse a HashList

HI,

How can I reverse a HashList?

I can convert it to ArrayList like this:

Hashtable catagoryTable = new Hashtable();
ArrayList entries = new ArrayList(catagoryTable)
entries.Reverse();

How can I convert it back to a Hashtable?

Thank you.
EndelmAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
To what end?!...

The insertion order of entries in a HASHTABLE is NOT preserved.

Entries in a HashTable are internally "ordered" based upon the Hash of each key.  So as you enter items, the order changes based on what it is doing internally with the keys to make lookups...

You, as the end user, have NO control over the order of entries in a HashTable.

See:
http://msdn2.microsoft.com/en-us/library/system.collections.hashtable.aspx

    "Represents a collection of key/value pairs that are organized based on the hash code of the key."
0
 
surajgupthaCommented:
Well u mean something apart from iterating through the array list and creating the hashtables in a for loop.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.