Hi,
I've a dictionary object:
Dictionary
<string, string[]> dictCompanies = new Dictionary<string, string[]>();How do sort this object on its key?
I tried using OrderBy like below, but it does no seem to work
dictCompanies .OrderByDescending(c=> c.Key);
I'm binding this dictionary object to a checkboxlist in aspx page.
I tried sorting this ListItemCollection using delegate...but still no luck...
Am i missing something here?
Thanks
Scott LyslePosted Jan 25, 2009, 6:39 PM
private void Form1_Load(object sender, EventArgs e)
{
var dictCompanies = new Dictionary<string, string[]>();
dictCompanies.Add("4", new string[] { "Gra", "Gre" });
dictCompanies.Add("3", new string[] { "Tro", "Tre" });
dictCompanies.Add("1", new string[] { "Una", "Uni" });
dictCompanies.Add("2", new string[] { "Doo", "DAA" });
var fullList = dictCompanies.Keys.ToList();
fullList.Sort();
foreach (string sKey in fullList)
{
textBox1.Text += sKey + Environment.NewLine;
}
}