Reputation: 1199
What means |= in c#?
Example:
int a= 0;
int b = a |= 5;
I can't find any hints for this.
Upvotes: 4
Views: 523
Reputation: 133
This is in the MSDN Library under operators for c#
http://msdn.microsoft.com/en-us/library/h5f1zzaw.aspx
Upvotes: 3
Reputation: 3689
Bitwise or.
Your snippet becomes.
int a = 0;
int b;
a = a | 5;
b = a;
In the end, a = b = 5
Upvotes: 2
Reputation: 14391
It is an assignment operator that performs a bitwise logical OR on integral operands and a logical OR on bool operands.
http://msdn.microsoft.com/en-us/library/h5f1zzaw(v=VS.100).aspx
Upvotes: 2
Reputation: 2401
"|" is a bitwise OR operator. http://msdn.microsoft.com/en-us/library/kxszd0kx(v=vs.71).aspx
So,
a |= 5;
is the same as
a = a | 5;
Upvotes: 4
Reputation: 770
|= is the OR assignment operator.
http://msdn.microsoft.com/en-us/library/h5f1zzaw.aspx
Upvotes: 4
Reputation: 33998
the OR assignment operator.
full explanation is here. http://msdn.microsoft.com/en-us/library/h5f1zzaw(v=vs.71).aspx
Upvotes: 12