On May 3, 4:43*pm, Jay Dee <first...@gmail.com> wrote:
> I would like to no how to convert an array of 16 Boolean values into
> an array of 2 bytes.
>
> I can find plenty of examples to get Booleans from bytes but can not
> get my head round how to do it in reverse.
Do you mean that you want to pack 16 boolean values into 16 bits
(which would be 2 bytes)?
If so, then by far the easiest way to do it and avoid messing with
bitwise operators is to use BitArray:
bool[] input = new bool[16];
byte[] output = new byte[2];
....
new BitArray(input).CopyTo(output, 0);
|