I have this scenario where user has its role
NormalUser
Custodian
Finance
both Custodian and Finance is a Super
Check out What does the [Flags] Enum Attribute mean in C#? for a more thorough explanation.
A "safer" way to declare flags is to use bit-shifting to ensure there's no overlap (as mentioned by @DaveOwen's answer) without figuring out the math yourself:
[Flags]
public enum MyEnum
{
None = 0,
First = 1 << 0,
Second = 1 << 1,
Third = 1 << 2,
Fourth = 1 << 3
}
There's also Enum.HasFlag
(possibly newer .NET than OP) for checking, rather than Expected & Testing == Expected