I was wondering, is there a way to convert a BitArray into a byte (opposed to a byte array)? I’ll have 8 bits in the BitArray..
BitArray b = new BitArray(8);
//in this section of my code i manipulate some of the bits in the byte which my method was given.
byte[] bytes = new byte[1];
b.CopyTo(bytes, 0);
This is what i have so far…. it doesn’t matter if i have to change the byte array into a byte or if i can change the BitArray directly into a byte. I would prefer being able to change the BitArray directly into a byte… any ideas?
You can write an extension method
You can use it like so
9 decimal = 1001 in binary