Operators like |= and &= work as bitwise operators on ints and longs…
int a = 123;
int b = 234;
a |= b;
Console.WriteLine(a); // outputs 251
But on a bool, it’s a logical operation:
bool a = true;
bool b = false;
a |= b;
Console.WriteLine(a); // outputs true
How do the ^=, &= and |= operators decide which manipulation to use when being applied to different data types?
The compiler decides, based on the static types of the expressions involved.