public static bool[] ReadBits(this byte[] bytes, int offsetBytes, int offsetBits, int countBits) { var totalBytes = Math.Ceiling((1.0 * offsetBits + countBits) / 8); var subBytes = bytes.GetPart(offsetBytes, (int)totalBytes).ToArray(); var bits = new BitArray(subBytes); var bitPart = bits.GetPart(offsetBits, countBits).ToArray(); return bitPart; //var bitArr = new BitArray(bitPart); //return bitArr.ToInt(); }