> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Conditional Logical OR

The `||` operator in C# is the conditional logical OR operator. It performs a logical OR operation using short-circuit evaluation. The right-hand operand is evaluated only if the left-hand operand does not definitively determine the outcome of the expression.

```csharp theme={"dark"}
var result = leftOperand || rightOperand;
```

## Evaluation Mechanics

For built-in boolean types, the operator processes operands from left to right and returns a `bool`:

1. If the left-hand operand evaluates to `true`, the expression yields `true`. The right-hand operand is bypassed entirely (short-circuited), and any side effects within it do not occur.
2. If the left-hand operand evaluates to `false`, the right-hand operand is evaluated, and its boolean value becomes the result of the entire expression.

## Truth Table and Execution Flow

The following table demonstrates the outcome and short-circuiting behavior for `bool` types:

| `leftOperand` | `rightOperand` | `result` | Was `rightOperand` evaluated? |
| :------------ | :------------- | :------- | :---------------------------- |
| `true`        | *any value*    | `true`   | **No**                        |
| `false`       | `true`         | `true`   | Yes                           |
| `false`       | `false`        | `false`  | Yes                           |

## Syntax Visualization of Short-Circuiting

```csharp theme={"dark"}
bool EvaluateRight() 
{
    Console.WriteLine("Right operand evaluated.");
    return true;
}

// "Right operand evaluated." is NOT printed to the console.
// The evaluation of the expression short-circuits after reading the 'true' literal.
bool shortCircuited = true || EvaluateRight();

// "Right operand evaluated." IS printed to the console.
// The left operand is false, forcing evaluation of the right operand.
bool fullyEvaluated = false || EvaluateRight();
```

## Technical Characteristics

* **Precedence:** The `||` operator has lower precedence than the conditional logical AND operator (`&&`) but higher precedence than the null-coalescing operator (`??`) and assignment operators (`=`).
* **Associativity:** It is left-associative. An expression like `a || b || c` is evaluated as `((a || b) || c)`.
* **Type Constraints:** For built-in types, the `||` operator is defined exclusively for `bool`. It does not support three-valued logic; attempting to use `||` with `bool?` (nullable boolean) operands results in compiler error CS0019. However, the operator can also be applied to `dynamic` operands (where binding is deferred to runtime) and qualifying user-defined types.
* **User-Defined Types:** The `||` operator cannot be explicitly overloaded. However, user-defined types can implicitly support the `||` operator by overloading the standard logical OR operator (`|`) alongside `operator true` and `operator false`. In this scenario, evaluating `x || y` returns an instance of the user-defined type `T`, not a `bool`. The evaluation resolves as follows:
  * If `T.true(x)` is true, the expression evaluates to `x` (short-circuited).
  * If `T.true(x)` is false, the expression evaluates to `x | y`.
* **Contrast with `|`:** Unlike the standard logical OR operator (`|`), which always evaluates both operands regardless of the left operand's value, `||` guarantees execution optimization via short-circuiting.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C# Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
