System.BitArray only implements the non-generic IEnumerable, which returns an Object for the IEnumerator.Current property. Does running a foreach over a BitArray - eg
foreach (bool b in bitArray)
{
// ...
}
box and unbox each and every bit value?
Looking at the bitarray enumerator in reflector, it looks like it does a fresh bitmask on every call of MoveNext() rather than something cleverer. Is there a more efficient way of enumerating a BitArray, or a replacement for BitArray that has the same storage characteristics? (List<bool> etc uses one byte per bool, rather than a single bit, so uses 8x as much space)