Here’s a slightly easier way to work with flag enumerations.
Consider this simple enumeration:
Normally, to check if a particular option has been supplied, you need to write a clumsy test:
Historically, this is what we’ve been stuck with - even in C# 2.0, because you can’t constrain a generic method to work
However, with Extension methods in C# 3.0, we can write a helper like this:
Which makes the test much easier to read:
Hope you find this useful!