C# - ushort array to multiple bits

160 Views Asked by At

I have a ushort[3] data read from device. Now I want to convert it to the following format:

Picture Here

The first word ushort[0] --> 16 bits

The second word ushort[1] --> 8 bits & 2 * 4-bits

The Third word ushort[2] --> 4 * 4bits


For example:

The ushort[3] is 3 256 16

After converting:

The first word 0000 0000 0000 0011

The second word ushort[1] --> 0 1 0000 0000

The Third word ushort[2] --> 0 0 1 0


At last store it as byte[30] in c#

I hope I have clearly explain this problem, and welcome any suggestions. Thanks!

0

There are 0 best solutions below