C# Bitwise Operator With Ints

后端 未结 3 1744
没有蜡笔的小新
没有蜡笔的小新 2021-01-25 09:00

What does this expression actually mean??

Note - the x and y vars are just sample values.

int x = 3; 
int y = 1; 

if ((x & y) !=0)

3条回答
  •  情深已故
    2021-01-25 09:22

    This checks whether x and y both have at least one common bit set. In the case of your example this would be the true.

提交回复
热议问题