Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,
C#
Hashtable ht = new Hashtable();

            ht.Add(1, "std1");
            ht.Add(2, "std2");
            ht.Add(3, "std3");
            ht.Add(4, "std4");

This is my hashtable.when i retrive data the ouput is 4 std4,3 std3,2 std2,1 std1;
but i need ouput1 std1,2 std2,3 std3,4 std4.......thanx
Posted
Updated 19-Dec-12 20:11pm
v2
Comments
okishore7 20-Dec-12 2:23am    
can u help me what is SortedDictionary.?
Kiran Susarla 20-Dec-12 5:09am    
This MSDN link has details about sorted dictionary.
http://msdn.microsoft.com/en-us/library/f7fta44c(VS.100).aspx

1 solution

From the output it looks like you want the output in sorted order. But sorting a hashtable is not suggested. If you still want to sort the hashtable, you can go through this link:
Sorting Hashtable[^]

The other way is instead of using the hashtable, you can use SortedDictionary.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900