I want Convert Byte to fixed size (size = 8) bit array
Want Behavior:
var bits = GetBits(0x00); // returned [0,0,0,0,0,0,0,0]
bits = GetBits(0x01); // returned [1,0,0,0,0,0,0,0]
bits = GetBits(0x0A); // returned [0,1,0,1,0,0,0,0]
I used below code but it didn't return what I want.
BitArray bits = new BitArray(byte);
You're using the wrong constructor.
Try this:
BitArray bits = new BitArray(new byte[] { 12 });
The constructor you're using is saying how long you want the bit array to be.