C# Bitwise Operator With Ints

后端 未结 3 1712
没有蜡笔的小新
没有蜡笔的小新 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:28

    if ((x & y) != 0)
    

    This would typically be used to determine whether the value x has a specific bit-flag (y) set. The AND operator returns an integer with only those bits set that are set in both operands.

提交回复
热议问题