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
}
Written by Wesley Lemos
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Bitwise
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#