I have a BitArray with the length of 8, and I need a function to convert it to a byte. How to do it?
Specifically, I need a correct function of ConvertToByte
BitArray bit=new BitArray(new bool[]
{
false,false,false,false,
false,false,false,true
});
//How to write ConvertToByte
byte myByte=ConvertToByte(bit);
var recoveredBit = new BitArray(new[] { myByte });
Assert.AreEqual(bit, recoveredBit);