c# 查找Dictionary中相同值的键
作者:
菜鸟的笔记 | 来源:发表于
2021-03-01 17:29 被阅读0次 #region MyRegion
Dictionary<int, int> dict = new Dictionary<int, int>();
public void Test()
{
dict.Add(1, 11);
dict.Add(2, 11);
dict.Add(3, 11);
dict.Add(4, 112);
dict.Add(5, 113);
var list = dict.GroupBy(kvp => kvp.Value).ToList();
foreach (var item in list)
{
//Debug.Log("相同的值 == " + item.Key);
foreach (var subitem in item)
{
Debug.Log("相同的值 Value == " + item.Key+" 相同值对应的键 key == " + subitem.Key);
}
}
}
#endregion
打印日志
![](https://img.haomeiwen.com/i14971803/feadf664dff66264.png)
image.png
本文标题:c# 查找Dictionary中相同值的键
本文链接:https://www.haomeiwen.com/subject/aobafltx.html
网友评论