title: Correct way to convert 8 bools into 1 byte
body: <p>Simple question: considering that a bool (true, false) is the same as a bit (1, 0), what is the correct way to convert eight bools into a byte in C#?</p>
  
  <p>Examples:</p>
  
  <p>true, true, true, true, true, true, true, true == 11111111 == 255</p>
  
  <p>true, false, false, false, false, false, false, false == 10000000 == 128</p>
  
  <p>false, false, false, false, false, false, false, false == 00000000 == 0</p>
  
  <p>The above is the first part. I want to create an extension method, like that:</p>
  
  <pre><code>    public static byte[] ToByteArray(this bool[] bitArray)
      {
            // stuff here
            return byteArray;    
      }
  </code></pre>
  
  <p>The result must be a byteArray that contains eight times less elements than the bool array.</p>