I have a BitArray with the length of 8, and I need a function to convert it to a byte. How to do it?
byte
Specifically, I need a correct function of Co
Co
This should work:
byte ConvertToByte(BitArray bits) { if (bits.Count != 8) { throw new ArgumentException("bits"); } byte[] bytes = new byte[1]; bits.CopyTo(bytes, 0); return bytes[0]; }