Rainer,
Use the constructor that takes a byte array, and do this:
byte[] Bits = new byte[2]{0xAA, 0x55};
BitArray MyBitArray = new BitArray(Bits);
As for reading from the bit array, there doesn't seem to be an easy way
to do it, short of iterating through the flags and setting each bit (similar
to the operation you used to populate the bit array).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Rainer Queck" <Ra****@noemail.noemail> wrote in message
news:ux****************@TK2MSFTNGP10.phx.gbl...
Hi NG
I have some questions concerning BitArrays.
Assumption : BitArray with 16 Bits
Is it possible to "load" a BitArray with a UInt16 Value with out iterating
it like:
UInt16 Bits = 0xAA55;
for (int i = 0 ; i<16 ; i++){
MyBitArray[i] = (Bits & Mask) >0 ;
Mask <<= 1;
}
and then, is there a way to "read" a BitArray like (without iterating like
above)
UInt16 Bits = MyBitArray.<some read method> ?
Thanks for hints and help.
Regards
Rainer