How to Compare Flags in C#?
In .NET 4 there is a new method Enum.HasFlag. This allows you to write: if ( testItem.HasFlag( FlagTest.Flag1 ) ) { // Do Stuff } which is much more readable, IMO. The .NET source indicates that this performs the same logic as the accepted answer: public Boolean HasFlag(Enum flag) { if (!this.GetType().IsEquivalentTo(flag.GetType())) { throw new … Read more