Does C# support struct bit definitions?

  • Thread starter Thread starter sygnosys
  • Start date Start date
S

sygnosys

Hi,
Does C# support struct bit definitions. For example is there a way to
declare somethink like this C/C++ Code:

struct CELL { // Declare CELL bit field
unsigned short character : 8; // 00000000 ????????
unsigned short foreground : 3; // 00000??? 00000000
unsigned short intensity : 1; // 0000?000 00000000
unsigned short background : 3; // 0???0000 00000000
unsigned short blink : 1; // ?0000000 00000000
} screen;

I looked through the MSDN and I think that it's not possible. So this
post it's to know if I'm correct or dead wrong.

Thanks
Cláudio Albuquerque
 
I looked through the MSDN and I think that it's not possible. So this
post it's to know if I'm correct or dead wrong.

You could simulate the same thing with properties.

Michael
 
Hi,
Does C# support struct bit definitions. For example is there a way to
declare somethink like this C/C++ Code:

struct CELL { // Declare CELL bit field
unsigned short character : 8; // 00000000 ????????
unsigned short foreground : 3; // 00000??? 00000000
unsigned short intensity : 1; // 0000?000 00000000
unsigned short background : 3; // 0???0000 00000000
unsigned short blink : 1; // ?0000000 00000000
} screen;

I looked through the MSDN and I think that it's not possible. So this
post it's to know if I'm correct or dead wrong.

Thanks
Cláudio Albuquerque

have a look at the BitVector32 struct..
 
Back
Top