title: merge two dictionaries Dictionary<string, Dictionary<string, Object>>
body: <p>This is kind-of related to this question, on how to merge two dictionaries in C#. An elegant Linq solution is presented, which is cool.</p>
  
  <p>However, that question relates to <code>Dictionary&lt;Object1, Object2&gt;</code>, whereas I have a dictionary where the value is a  <code>Dictionary&lt;string, Object&gt;</code>.</p>
  
  <p>I am looking for a solution for merging tow <code>Dictionary&lt;string, Dictionary&lt;string, Object&gt;&gt;</code>, with the following requirements:</p>
  
  <ul>
  <li>Without duplicating key in the dictionary result of two dictionary, </li>
  <li><p>For each dictionary I think a grouping by KEY can be part of the solution but after ...</p>
  
  <pre><code>internal static Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt; OperationDic(Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt; a, Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt; b, string operation)`
      { 
          switch (operation) 
          {
              case "+":
                  var result =  a.Concat(b).GroupBy(d =&gt; d.Key).ToDictionary (d =&gt; d.Key, d =&gt; d.First().Value); 
                  return result;               
              default: 
  
                  throw new Exception("Fail ...");
          }             
      }
  </code></pre></li>
  </ul>