title: Compare Keys in Two Dictionaries
body: <p>I'm trying to compare two dictionaries, the program is written in C# Visual Studio 2010.</p>
  
  <pre><code>Dictionary&lt;int, string&gt; members1 = new Dictionaries&lt;int, string&gt;{
      {1, "adam"},
      {2, "bob"},
      {3, "cameron"}
  }
  
  Dictionary&lt;int, string&gt; members2 = new Dictionaries&lt;int, string&gt;{
      {1, "adam"},
      {2, "bill"},
      {4, "dave"}
  }
  </code></pre>
  
  <p>I would like to find the same id (key), and it doesn't matter if the name (value) is the same or not.</p>
  
  <p>I've been searching and found <code>Intersect</code> and <code>Except</code>, but I don't think it work quite the way I wanted it.</p>
  
  <p>With the example above, if I call an <code>Intersect</code> function, I want it to return <code>List&lt;int&gt;{1, 2}</code>.</p>
  
  <p>If I call something like <code>members1.Except(members2)</code>, I want it to return</p>
  
  <pre><code>Dictionary&lt;int, string&gt; intersectMembers{
      {1, "adam"},
  }
  </code></pre>
  
  <p>A solution I thought of doing is to write 2 for-loops and using <code>dictionary.Contains(key)</code> to get the result I want.</p>
  
  <p>Is there a more straight forward way of doing this?</p>
  
  <p>Thanks</p>