public void WriteBoolArray(bool[] booArray) { CheckBufferPoll(booArray == null ? 1 : booArray.Length + 5); if (booArray == null) { _ms.WriteByte((byte)ArrayTypeFlag.NULL); return; } else if (booArray.Length == 0) { _ms.WriteByte((byte)ArrayTypeFlag.Empty); return; } ArrayTypeFlag flag = ArrayTypeFlag.DEFAULT; int len = booArray.Length; var bytelen = CompressInt32(len); if (bytelen.Length == 1) { flag = ArrayTypeFlag.ByteLen; } else if (bytelen.Length == 2) { flag = ArrayTypeFlag.ShortLen; } _ms.WriteByte((byte)flag); _ms.Write(bytelen, 0, bytelen.Length); BitArray ba = new BitArray(booArray); var btarray = BitHelper.ConvertToByteArray(ba); foreach (byte b in btarray) { _ms.WriteByte(b); } }