My question is fairly simple. Take this enum:
public enum Foo
{
Foo = 1,
Bar = 2,
FooBar = 4
}
Now when applying the AND/OR bitwise operator with a zero on one side I do not need a cast and everything works fine e.g.
Foo f = Foo.Bar & 0; // works perfectly fine and compiles
As soon as I change the natural number to any other value then 0, I need to cast the number.
Foo f = Foo.Bar & 1; // doesn't work nor compile
The error would be the following:
Operator '&' cannot be applied to operands of type 'Foo' and 'int'
Now how comes, that 0 does not to be casted where as any number as to be casted to the given enum?