CSharp examples for Language Basics:Operator
C# supports the following bitwise operators:
Operator | Meaning | Sample expression | Result |
---|---|---|---|
~ | Complement | ~0xfU | 0xfffffff0U |
& | And | 0xf0 & 0x33 | 0x30 |
| | Or | 0xf0 | 0x33 | 0xf3 |
^ | Exclusive Or | 0xff00 ^ 0x0ff0 | 0xf0f0 |
<< | Shift left | 0x20 << 2 | 0x80 |
>> | Shift right | 0x20 >> 1 | 0x10 |