public static void Flip(this BitArray bits, int startIdx, int endIdx) { for (int i = startIdx; i < endIdx; i++) { bits[i] = !bits[i]; } }