What does | operator mean in statement looking like that:
public int IntProperty => (booTrue ? 1 : 0) | (fooTrue ? 2 : 0);
I'm familiar with => and ? but I've never seen | used like that.
It`sa bitwise or . If we look at the values in your code you could have:
00
01
10
So, if booTrue
is true and fooTrue
is true, it will be 1 | 2
1 | 2
. As it's a bitwise or, it will be 01 | 10
01 | 10
=> 11
in decimal => 3 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.