Question about | = in C #

What does | = in C #?

Example:

int a= 0; int b = a |= 5; 

I can not find any hints for this.

+4
source share
6 answers

assignment operator OR.

full explanation here. http://msdn.microsoft.com/en-us/library/h5f1zzaw(v=vs.71).aspx

+12
source
+4
source

"|" is a bitwise OR operator. http://msdn.microsoft.com/en-us/library/kxszd0kx(v=vs.71).aspx

So,

 a |= 5; 

coincides with

 a = a | 5; 
+4
source

This is in the MSDN library under operators for C #

http://msdn.microsoft.com/en-us/library/h5f1zzaw.aspx

+3
source

This is an assignment operator that executes 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

+2
source

Bitwise or.

Your fragment will be.

 int a = 0; int b; a = a | 5; b = a; 

In the end, a = b = 5

+2
source

All Articles