Bit-packed data management using C #

I am working on a TCP application that processes bit messages, which means: sent / received messages are not byte aligned. For example, 3 bits represent field 1, where 19 bits can represent field 2. My question is: does anyone know a C # library that can accept a set of bytes and set / receive an arbitrary range of bits in these bytes? I saw and created similar utilities in C / C ++, but I need a 100% C # solution, and I don't want to reinvent the wheel again.

I looked at the BitArray class, but it does not allow reference to arbitrary bit ranges.

+5
source share
2 answers

CodeProject - , BitStream, #.

+3

- bcl, , . (shift, and, or,...), .

, , 2 5 , :

int extract = (source & 0x7C) >> 2;
+2

All Articles