【发布时间】:2015-07-10 18:26:40
【问题描述】:
我想按键对字典进行排序,然后从该字典中取出所有值并将它们放入一个数组中。
例如,
Dictionary<int, string> customerNamesByIDs = new Dictionary<int, string>();
customerNamesByIDs.Add(9, "joe");
customerNamesByIDs.Add(2, "bob");
//sort customerNamesByIDs by int
//take sorted dictionary and put them into an array
List<string> customerNames;
//customerNames[0] == "bob";
//customerNames[1] == "joe";
似乎应该有一个简单的方法来做到这一点,但我完全不知道怎么做。感谢您的宝贵时间!
【问题讨论】:
标签: c# linq list dictionary