I have this BitArray that contains the following:
byte[] myBytes = {0, 0, 2, 176, 168, 3, 19, 0};
BitArray myBitArr = new BitArray(myBytes);
The result is some how revered on the disp:(EDIT: THIS IS NOT THE ISSUE)
00000000 00000000 01000000 00001101 00010101 11000000 11001000 00000000
reveres, is:
00000000 000000**00 00000010 1011**0000 10101000 00000011 00010011 00000000
To get the bits out from the myBitArr I use the following
bool[] myNumbers = GetBitSBiArray(myBitArr, 36, 50);
with this helping method
private static bool[] GetBitSBiArray(BitArray ba, int from, int to)
{
bool[] temp = new bool[to - from];
int t = 0;
for (int i = ba.Length - to; i < ba.Length - from; i++)
{
temp[t] = ba.Get(i);
t++;
}
return temp;
}
the method above returns somehow the wrong result:
00010000 000000 (14bit)
the correct result is:
00000000 101011 (14bit) or 43
i'm not interested in overflow or other exceptions for now.
what is wrong with my method and what alternatives do i have?