When a method has default arguments that are OR'ed together, the resulting int will always be zero.
const int BAR_1 = 2; const int BAR_2 = 4; void Foo(int i = BAR_1 | BAR_2) { PrintFormat("Foo %1", i); } Foo();
Result:
Foo 0
When a method has default arguments that are OR'ed together, the resulting int will always be zero.
const int BAR_1 = 2; const int BAR_2 = 4; void Foo(int i = BAR_1 | BAR_2) { PrintFormat("Foo %1", i); } Foo();
Result:
Foo 0
Default values are not evaluated, this has been an issue for as long as I can remember. It's not entirely useful for me, but I'll follow the ticket.
Oh they are evaluated, they just can't be OR'ed together. Using a single constant or enum works absolutely fine as default argument.
I.e. this is fine:
void Foo(int i = BAR_1) { PrintFormat("Foo %1", i); } Foo();
Result:
Foo 2