C# Bitwise Operators Explained
The C# language provides the following bitwise operators:
- Bitwise AND: Performs an AND operation on each bit of two integers, resulting in 1 only if both bits are 1.
- (Bitwise OR): Performs the OR operation on each bit of two integers, resulting in 0 only if both bits are 0.
- Bitwise XOR: Perform an XOR operation on each bit of two integers, resulting in 1 only if the two bits are different.
- Bitwise negation: Invert each bit of an integer, changing 0 to 1 and 1 to 0.
- Left shift: move all the bits of an integer to the left by a specified number of positions, filling the empty spaces on the right with zeros.
- Right shift: Shift all the bits of an integer to the right by a specified number of positions, filling the empty left positions with the original sign bit.
These bitwise operators can be used to manipulate the binary bits of integers, often used in areas such as bit masking and permission management.