Best way to get all bits of an enum flag?

Viewed 12365

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.

5 Answers
Related