9

In some code i found this |= operator used to return a uint but i can find something about it on the internet and i wanna understand how it works and what are the return values in this case.

public uint Mask { get { uint num = 0; if (_0) num |= 1U; if (_1) num |= 2U; if (_2) num |= 4U; return num; } } 

a detailed answer will be much appreciated.

6

1 Answer 1

29

You know how x += 1 means x = x + 1, well x |= 1 means x = x | 1. Of course | means bitwise OR.

Sign up to request clarification or add additional context in comments.

1 Comment

i wasn't expecting that, what a shame :D. thanks for your answer dude.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.