Last Updated: February 25, 2016
·
289
· anisanwesley

Check enum contains expected value

Code

internal enum Extensive {  }

        public static bool IsBitwise(this Enum pos, Enum comparer)
        {
            return ((Extensive)pos & (Extensive)comparer) != 0;
        }

Usage

public enum Test { valueA, valueB, valueC }

public void Method()
{
       var test = Test.valueA | Test.valueC;

       test.IsBitwise(Test.valueA); //true
       test.IsBitwise(Test.valueB); //false
       test.IsBitwise(Test.valueC); //true
}