public Int32 ReadBitsBigEndian(int length) { Int32 bits = 0; while (length > 0) { bits <<= 1; bool bit = ReadBit(); bits += bit ? 1 : 0; length -= 1; } return bits; }