【发布时间】:2014-07-07 05:35:06
【问题描述】:
今天对你来说可能是一个简单的问题,但我目前正在兜圈子。考虑这种情况:
var tempDictionary = new Dictionary<string, int>();
tempDictionary.Add("user 1", 5);
tempDictionary.Add("user 2", 3);
tempDictionary.Add("user 3", 5);
Console.WriteLine(tempDictionary.Min(x => x.Key) + " => " tempDictionary.Min(x => x.Value);
以上返回“用户 1 => 3”。
您将如何返回字典中具有最低值的键?我之后的输出看起来像这样:“user2 => 3”
有什么想法吗?
【问题讨论】:
-
Good way to get the key of the highest value of a Dictionary in C# 的可能副本(以及对答案的编辑以反映这一点)
标签: c# linq dictionary