小编Dav*_*ers的帖子

如何在Dictionary <string,List <int >>中将List <int>分组,其中列表是相同的?

我想获取a Dictionary<string, List<int>>然后为字典中的所有重复列表创建组.

Dictionary<string, List<int>> AllLists = new Dictionary<string, List<int>>()
{
    {"one", new List<int>() {1, 2, 3, 4, 5}},
    {"two", new List<int>() {1, 2, 3, 4, 5}},
    {"three", new List<int>() {1, 1, 1, 1, 1}}
};

var ListGroups = AllLists.GroupBy(p => p.Value);
Run Code Online (Sandbox Code Playgroud)

这应该将带有匹配列表的字典索引分组到它们自己的组中,但它只是为字典中的每个索引创建一个组.我究竟做错了什么?

.net c# linq

2
推荐指数
1
解决办法
179
查看次数

标签 统计

.net ×1

c# ×1

linq ×1