Difficulty: Easy
Correct Answer: The | operator can be used to put ON a bit.
Explanation:
Introduction / Context:
This question covers the bitwise OR operator in C#. It is often used in low-level programming to manipulate individual bits.
Given Data / Assumptions:
Concept / Approach:
In bitwise OR, any bit position where at least one operand has 1 results in 1. This is often used to set (turn ON) bits in a bitmask.
Step-by-Step Solution:
Verification / Alternative check:
Apply OR with a mask: value | 0x04 sets bit 2 regardless of its previous state.
Why Other Options Are Wrong:
| does not turn OFF, invert, or directly test bits. It only sets ON bits when combined with 1.
Common Pitfalls:
Confusing | with & (AND) or ^ (XOR).
Final Answer:
The | operator can be used to put ON a bit.
Discussion & Comments