In C #, what does' | = '?
8 answers
This is a bit of a wise assignment. This is roughly shortened for the following
x |= y; x = x | y;
Note. This is not the case because the C # specification ensures that side effects x
only appear once. Therefore, if it x
is a complex expression, a fun bit of code is generated for the compiler to ensure that 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
+14
source to share
| = is a bitwise assignment operator. Check out the msdn documentation here http://msdn.microsoft.com/en-us/library/h5f1zzaw(v=vs.100).aspx
0
source to share
http://msdn.microsoft.com/en-us/library/h5f1zzaw(v=vs.80).aspx is your specific
http://msdn.microsoft.com/en-us/library/6a71f45d(v=vs.80).aspx if you're curious and want a full list
0
source to share