I need to translate a C struct to C# which uses bit fields.
typedef struct foo
{
unsigned int bar1 : 1;
unsigned int bar2 : 2;
unsigned int bar3 : 3;
unsigned int bar4 : 4;
unsigned int bar5 : 5;
unsigned int bar6 : 6;
unsigned int bar7 : 7;
...
unsigned int bar32 : 32;
} foo;
Anyone knows how to do this please?
You could use the
BitArray
class for the framework. Look at the msdn article.