C# deserializing a binary structure with bitfields - how to do? -


i have c struct defined in way similar this:

struct teststruct {     uint flag1 :2;     uint flag2 :2;     uint flag3 :2;     uint flag4 :2;      uint value1; } teststruct; 

i know can deserialize binary struct using structlayout attribute , marshal.ptrtostructure(). there way binary fields shown in structure 1 value 2 bits long?

thanks in advance.

there no direct support such structure in c#. have use integral type holding bits , extract fields afterwards.

see solution similar problem @ bit fields in c#


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -