Sort HashTable

Madhu.b.rokkam
Posted by Madhu.b.rokkam under C# category on | Points: 40 | Views : 7771
Hashtable hash = new Hashtable();
hash.Add("1", "Hello");
hash.Add("2", "Dotnet");
hash.Add("3", "funda");

List<int> lst = new List<int>();

foreach (var key in hash.Keys)
{
lst.Add(int.Parse(key.ToString()));
}

lst.Sort();

foreach (var item in lst)
{
Console.WriteLine(string.Format("{0},{1}", item, hash[item.ToString()]));
}

Console.Read();

Comments or Responses

Login to post response