title: How to select all Key Value Pairs from a dictionary for some keys
body: <p>I have a Key class contain some members. How would I filter a dictionary when I only have one member of the key object. Here is some code:</p>
  
  <pre><code>class Key
  {
      public int a { get; set; }
      public int b { get; set; }
  }
  
  public class KeyEqualityComparer : IEqualityComparer&lt;Key&gt;
  {
      public int GetHashCode(Key k)
      {
          return (k.a + k.b).GetHashCode();
      }
  
      public bool Equals(Key lhs, Key rhs)
      {
          return ((lhs.a == rhs.a) &amp;&amp; (lhs.b == rhs.b));
      }
  }
  
  static Dictionary&lt;Key, int&gt; Data = new Dictionary&lt;Key, int&gt;( new KeyEqualityComparer() );
  
  static void Main(string[] args)
  {
      Data.Add(new Key() { a = 0, b = 0 }, 99);
      Data.Add(new Key() { a = 1, b = 0 }, 99);
  
      // select all keys value pairs where the key contains a == 0
  }
  </code></pre>