Given the enum:
[Flags]
enum foo
{
a = 1,
b = 2,
c = 4
}
then
foo example = a | b;
If I don't know if foo contains c
, previously I have been writing the following
if (example & foo.c == foo.c)
example = example ^ foo.c;
Is there a way to do this without checking for the existance of foo.c
in example
?
As when it comes to additions, I can just do an OR
, and if the enum value already exists in example
then it doesnt matter.