Reproducing some bit shift code from C++ to C#

bit-shift, c#, c++

Solution

`MASK(x)` constructs a number by `OR`-ing in a number `x` with a binary number `10000000000000000` (one shifted to the left 16 times).

In C# you can use an expression directly, like this:

enum FOO {
    FOO_1 = 0,
    FOO_2,
    // etc
}

enum DISP
{
    DISP_1 = (1<<16) | (int)(FOO.FOO_1),
    DISP_2 = (1<<16) | (int)(FOO.FOO_2),
    // etc
}

Problem

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.

Original source