I can't seem to Google it - doesn't appear to like the syntax in the search string. Thank you for the help.
This is a bit wise assignment. It's roughly shorthand for the following
x |= y;
x = x | y;
Note: It's not truly the above because the C# spec guarantees the side effects of x
only occur once. So if x
is a complex expression there is a bit of fun code generated by the compiler to ensure that the side effects only happen once.
Method().x |= y;
Method().x = Method().x | y; // Not equivalent
var temp = Method();
temp.x = temp.x | y; // Pretty close
The expression a |= b
is equivalent to the assignment a = a | b
, where |
is the bitwise OR operator.*
* Not entirely, but close enough for most purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With