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
Post a Comment