title: calculate number of true (or false) elements in a bool array?
body: <p>Suppose I have an array filled with Boolean values and I want to know how many of the elements are true.</p>
  
  <pre><code>private bool[] testArray = new bool[10] { true, false, true, true, false, true, true, true, false, false };
  
  int CalculateValues(bool val)
  {
      return ???
  }
  </code></pre>
  
  <p>CalculateValues should return 6 if val is true, or 4 if val is false.</p>
  
  <p>Obvious solution:</p>
  
  <pre><code>int CalculateValues(bool val)
  {
      int count = 0;
      for(int i = 0; i&lt;testArray.Length;i++)
      {
          if(testArray[i] == val)
              count++;
      }
      return count;
  }
  </code></pre>
  
  <p>Is there an "elegant" solution?</p>