I’m trying to convert an enum from C++ code over to C# code, and I’m having trouble wrapping my head around it. The C++ code is:
enum FOO {
FOO_1 = 0,
FOO_2,
// etc
}
#define MASK(x) ((1 << 16) | (x))
enum DISP
{
DISP_1 = MASK(FOO_1),
DISP_2 = MASK(FOO_2),
// etc
}
What I don’t understand is what MASK is doing, and how I can either emulate the functionality in C#, or understand what it’s doing and set the enum DISP manually without it.
I’m not sure what I’m saying is making sense, but that’s to be expected when I’m not entirely certain what I’m looking at.
MASK(x)constructs a number byOR-ing in a numberxwith a binary number10000000000000000(one shifted to the left 16 times).In C# you can use an expression directly, like this: