What is the operator `|=`? How can I implement this in C#?

后端 未结 2 1627
醉酒成梦
醉酒成梦 2020-12-19 22:56

What is the C++ code below doing? More specifically, what is the operator |=?

long liFaultFlags = 0;

for (int i = 0; i < FAULTCOUNT; i++)
{
         


        
相关标签:
2条回答
  • 2020-12-19 23:00

    The operator |= does bitwise OR and assignment rolled into one (much like += does integer addition and assignment together).

    It's exactly the same in C#.

    0 讨论(0)
  • 2020-12-19 23:01

    It is the bitwise OR operator and is equivalent to

    liFaultFlags = liFaultFlags | (1<<i);
    

    You would write that line in exactly the same way in C#.

    0 讨论(0)
提交回复
热议问题