今天对您来说可能很简单,但我现在正在兜圈子。考虑以下情况:
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);
上面的代码会返回 "user 1 => 3"。如何获取字典中值最小的键?我希望得到的输出格式为: "user2 => 3"。
有什么想法吗?