Flagged enum equation logic
Posted on 2007-11-13
Suppose I have:
None = 0,
Apple = 1,
Orange = 2,
Peach = 4,
Banana = 8
and then I initialize a avriable:
Fruits fruits = Fruits.Apple | Fruits.Orange | Fruits.Banana;
how do I then find out if "fruits" variable is equal to "Banana"
It would be really great if I could do something like this:
if (fruits == Fruits.Banana)
// do something
but unfortunately, it's not that convenient.