7
Answers

C# Logical operation

Sam

Sam

12y
2.8k
1

Hi,
I have an  array double[] MyArray (32 bits) and a variable ushort MyDevice (16 bits).

I wish to load the ushort MyDevice 16 bits to the upper 16 bits of the double[] MyArray
without affecting the lower array bits, but I get casting errors.
(Both work  in C++) but not in C# (it's too safe!).

Have tried:

MyArray[1]  |=  MyDevice << 16;

and

MyArray[1] & 0xFFFF0000 = MyDevice;

I get errors in both cases.

Can anyone advice?

Thanks

Answers (7)