Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-) Dictionary<String,List<String>&g_C#_Linq - Fatal编程技术网

C# 这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-) Dictionary<String,List<String>&g

C# 这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-) Dictionary<String,List<String>&g,c#,linq,C#,Linq,这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-) Dictionary<String,List<String>> DictOne=new Dictionary<String,List<String>>() Dictionary<String,List<String>> DictTwo=new Dic


这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)这只是两本词典的浓缩。我需要基于值而不是keyWell,问题有点神秘,不是吗?;-)
  Dictionary<String,List<String>> DictOne=new Dictionary<String,List<String>>()
  Dictionary<String,List<String>> DictTwo=new Dictionary<String,List<String>>()

 DictOne


KeyOne     "A"
           "B"

KeyTwo     "C"
           "D"

KeyThree   "X"
           "Y"



DictTwo

Key1      "X"
          "Z"
          "Y"

Key2      "A"


Key3     "C"
         "D"

Key4     "M"
         "N"
Dictionary<String,List<String>> DictThree=new Dictionary<String,List<String>>()
DictThree

KeyOne   "A"
         "B"

KeyTwo   "C"
         "D"

KeyThree "X"
         "Y"
         "Z"

Key4     "M"
         "N"
Dictionary<String, List<String>> DictThree = DictOne.Concat(DictTwo);
Dictionary<String, List<String>> DictThree = DictOne.Concat(DictTwo).ToDictionary(x => x.Key);
var dict3 = DictOne
    .Concat(DictTwo)
    .GroupBy(x => x.Key)
    .ToDictionary(x => x.Key, x => x.SelectMany(y => y.Value).ToList());
var dictThree = (from kv in dictOne.Concat(dictTwo)
                  group kv.Value by kv.Key)
   .ToDictionary(k => k.Key, v => v.SelectMany(l => l).Distinct().ToList());
var group1 = new string[][] { new[] { "A", "B" }, new[] { "C", "D" }, new[] { "X", "Y" } };
var group2 = new string[][] { new[] { "X", "Y", "Z" }, new[] { "A" }, new[] { "C", "D" }, new[] { "M", "N" } };

// For each array in group1, check if it has matching array in group2, if
// it does, merge, otherwise just take the array as is.
var group1Join = from g1 in group1
                 let match = group2.SingleOrDefault(g2 => g1.Intersect(g2).Any())
                 select match != null ? g1.Union(match) : g1;

// Take all the group2 arrays that don't have a matching array in group1 and
// thus were ignored in the first query.
var group2Leftovers = from IEnumerable<string> g2 in group2
                      where !group1.Any(g1 => g2.Intersect(g1).Any())
                      select g2;

var all = group1Join.Concat(group2Leftovers);