title: Merging Dictionary containing a List in C#
body: <p>This is kind-of related to <a href="https://stackoverflow.com/questions/294138/merging-dictionaries-in-c">this question</a>, 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>List&lt;Object2&gt;.</code></p>
  
  <p>I am looking for a solution for merging a <code>Dictionary&lt;Object1, List&lt;Object2&gt;&gt;,</code> with the following requirements:</p>
  
  <ul>
  <li>If Dictionary1 contains the same key as Dictionary2, then their <code>List&lt;Object2&gt;</code> lists should be combined. You would end up with a new key-value-pair with the shared key, and the combined lists from the two dictionaries.</li>
  <li>If Dictionary1 contains a key that Dictionary2 doesn't then the <code>List&lt;Object2&gt;</code> list from Dictionary1 should become the value, and vice versa.</li>
  </ul>
  
  <p>This may not be possible in Linq, or it may be worth writing it out longhand with for loops and the like, but it would be nice to have an elegant solution.</p>