> ## 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# Range

The `..` (range) operator constructs a `System.Range` struct that represents a contiguous sub-segment of a collection. It serves as syntactic sugar for defining boundaries, utilizing `System.Index` types to specify an inclusive lower bound and an exclusive upper bound.

## Syntax and Operands

The operator accepts two optional operands. Because both operands are optional, the operator supports four distinct syntax variations:

* **Left operand:** The inclusive start index. If omitted, it defaults to `0` (the beginning of the collection).
* **Right operand:** The exclusive end index. If omitted, it defaults to `^0` (the end of the collection).

```csharp theme={"dark"}
Range explicitBounds = 2..5; // Index 2 (inclusive) to Index 5 (exclusive)
Range openEnd        = 2..;  // Index 2 (inclusive) to the end of the collection
Range openStart      = ..5;  // Beginning of the collection to Index 5 (exclusive)
Range openBoth       = ..;   // The entire collection (0 to ^0)
```

## Type Resolution and Compilation

Operands supplied to the `..` operator must evaluate to type `int` or `System.Index`. When standard integers are provided, the compiler implicitly converts them to `System.Index` structs.

During compilation, the `..` syntax is lowered directly into an instantiation of the `System.Range` struct via its constructor.

```csharp theme={"dark"}
// Source syntax using the range operator (..) and index from end operator (^)
Range range = 1..^1;

// Lowered compiler translation
Index start = new Index(value: 1, fromEnd: false);
Index end = new Index(value: 1, fromEnd: true);
Range loweredRange = new Range(start, end);
```

## Operator Characteristics

* **Associativity:** The `..` operator is non-associative. Chaining the operator (e.g., `a..b..c`) is syntactically invalid and produces a compiler error.
* **Precedence:** It evaluates with lower precedence than arithmetic operators (like `+` or `*`) but higher precedence than relational and equality operators (like `<` or `==`).
* **Immutability:** The `System.Range` struct generated by the operator is a `readonly struct`. Its `Start` and `End` properties cannot be mutated after initialization.

<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>
