title: Using a Boolean Array as Custom Dictionary Key
body: <p>I am trying to make a Dictionary in C# that uses a boolean array for its keys. </p>
  
  <pre><code> Dictionary&lt;bool[], string&gt; 
  </code></pre>
  
  <p>The bool array has fixed length of 1000, and all are the same length. I'm having trouble with the hashcode and the common method  of an 'exclusive or' doesn't make as much sense because of the length of the array.</p>
  
  <p>Similar questions on StackOverflow are addressed with the 'exclusive or' in the GetHashCode method. I don't think that works in this context. I would like to use it as:</p>
  
  <pre><code> Dictionary&lt;bool[], string&gt; myDict = 
               new Dictionary&lt;bool[], string&gt;(EqualityComparer);
  </code></pre>
  
  <p>where EquaityComparer does something like:</p>
  
  <pre><code>   public class EqualityComparer : IEqualityComparer&lt;bool[]&gt;
      {
          public bool Equals(bool[] x, bool[] y)
          {
              return x.SequenceEqual(y);
          }
  
          public int GetHashCode(bool[] x)
          {
              // this part doesn't work correctly
              int hc = x.GetHashCode();
              return hc;
          }
      }
  </code></pre>
  
  <p>Of course all of the usual concerns about the bool array being mutable and the size of any derived key being relevant to performance apply here...though I don't have a solution.</p>