【发布时间】:2015-09-06 21:44:35
【问题描述】:
好的,这里有一个简单的字典
Dictionary<string,int> dicClusters=new Dictionary<string,int>();
dicClusters.Add("A",1);
dicClusters.Add("B",1);
dicClusters.Add("C",2);
dicClusters.Add("D",3);
所以我想由此组成如下列表
List<List<string>> lstGroupedByKeys=dicClusters.GroupBy(pr => pr.Value)...
结果是
first list {"A","B"}
second list {"C"}
third list {"D"}
我可以使用多个 foreach 或使用 for 循环对其进行编码,但是我相信它可以使用 linQ 来完成,我想学习 ty
c#.NET 4.5.2
【问题讨论】:
标签: c# linq dictionary group-by