C# enum gotcha!
If you define an enum with the Flags attribute, you expect that when you do an "&" operation with an enum value, you will get back the enum value you are "&" with, only if it contains within the value.
Wrong!
If you have a enum value with its numeric value set to "0", and you do:
value & zeroValue == zeroValue
You will always get zeroValue back, even if the actual enum value never had the zero value specified!!
Wrong!
If you have a enum value with its numeric value set to "0", and you do:
value & zeroValue == zeroValue
You will always get zeroValue back, even if the actual enum value never had the zero value specified!!
Comments
Post a Comment