日期:2014-05-17 浏览次数:22124 次
Dictionary<string, int> dict = new Dictionary<string, int>();
dict.OrderBy(d => d.Value).Select(d => d.Key).FirstOrDefault();
Dictionary<string, int> dict = new Dictionary<string, int>();
dict.Add("1", 1);
dict.Add("2", 2);
dict.Add("3", 3);
dict.Add("4", 4);
dict.Add("5", 1);
var minKey = (from d in dict orderby d.Value ascending select d.Key).First();
//考虑到不止一条的情况,分两步查询最小值的所有Key,这样的写法可能更好看懂
var allMinKeys = (from d in dict where d.Value == dict[minKey] select d.Key).ToArray();