title: Multi-key dictionary with optional keys
body: <p>I have a need for a dictionary with multiple keys of 2 different types (int and string, both unique, so they can appear only inside of 1 key). Here is an example: group information (GroupInfo) can be queried by either GroupdId or one of the member names:</p>
  
  <pre><code>
  GroupId   MemberNames           GroupInfo
  {1,       John, Mary, Joe} ==>  {GroupInfo}
  </code></pre>
  
  <p>So group info should be returned when requested by either id (1) or one of the member names (John).</p>
  
  <p>My first solution was to create a key that wraps GroupdId and MemberNames with overridden Equals method that compares GroupIds and looks up a list of members. However to make these entries equal:</p>
  
  <pre><code>
  GroupId   MemberNames          
  {0,       John}
  {1,       null}
  {1,       Mary}
  </code></pre>
  
  <p>GetHashCode has to return the same const value. This will result in a dictionary becoming a linked list and performance degrading to O(N) lookup in the best case scenario.</p>
  
  <p>The other solution is to keep 2 dictionaries separately: GroupId ==> GroupInfo, MemberName ==> GroupInfo. </p>
  
  <p>Any other ideas?</p>