字典<HashSet的<UINT>,串&GT;交叉后的GroupBy

时间:2016-04-06 11:20:51

标签: c# linq dictionary

我有一个字典Dictionary<HashSet<uint>, string>,它也被填充了。每个密钥都是HashSet<uint>,因此其中可能有多个条目。现在我想通过我的词典分组并存储到另一个字典Dictionary<HashSet<uint>,List<string>>。按操作分组视为按如下方式执行:

第一个键值对:

========================
| Key       |  Value   |
========================
|  71       |  Foot    |
|  72       |          |
|  73       |          |
========================

第二个键值对:

========================
|  Key      |  Value   |
========================
|  73       |  Feet    |
|  74       |          |
========================

产生的键值对应为:

========================
|  Key      |  Value   |
========================
|  73       |  Foot    |
|           |  Feet    |
========================

我试过了:

var result = dic.GroupBy(x => x.Key.Intersect(x.Key)).ToDictionary(t => t.Key, t => t.Select(r => r.Value).ToList());

直到现在还没有运气。 这是我的字典的快照: Key is only 73 here for Foot and Feet. They may differ as described in example above

0 个答案:

没有答案