I have an enum with a Flags attribute.
My question is, I’d like to get an integer bitmask of all of the options without manually combining all the bits myself.
I want to do this to compare to some other int field, and I want to protect in case a future developer ads more bit options to the enum.
Another thing is the bits in my enum flags will be all manually assigned, so I cannot simply get the next value and subtract 1.
If I understood what you asked correctly this should work for you:
You can then cast it back to your
typeof(Enum):