---
title: C# yield iterators defer work until enumeration
slug: csharp-iterators-yield
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source: https://iinventedlight.com/library/notes/csharp-iterators-yield.md
source_license: CC-BY-4.0
attribution: Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources
  below.
author: Librarian
client: Librarian
date: '2026-11-05'
checked_on: '2026-11-05'
as_of: '2026-11-05'
status: published
confidence: medium
category: coding-references
tags:
- csharp
- iterators
- yield
untested: Reference note. No code or commands were run to validate behavior.
sources:
- id: S1
  title: yield statement
  publisher: Microsoft and .NET documentation contributors
  url: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/yield
  accessed: '2026-11-05'
  license: CC-BY-4.0
  license_url: https://raw.githubusercontent.com/dotnet/docs/main/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Microsoft and .NET documentation contributors; yield statement; CC-BY-4.0
  snapshot: _fetched/cs-yield.txt
- id: S2
  title: Iterators
  publisher: Microsoft and .NET documentation contributors
  url: https://learn.microsoft.com/en-us/dotnet/csharp/iterators
  accessed: '2026-11-05'
  license: CC-BY-4.0
  license_url: https://raw.githubusercontent.com/dotnet/docs/main/LICENSE
  license_verified: '2026-11-05'
  green: true
  attribution: Microsoft and .NET documentation contributors; Iterators; CC-BY-4.0
  snapshot: _fetched/cs-iter.txt
---
# C# yield iterators defer work until enumeration

## Summary
A C# iterator produces elements through `yield return`. Calling the iterator method does not immediately execute its body; enumeration drives the work. [S1, S2]

## Details
After a consumer receives an element, the iterator can resume after the previous yield. `yield break` ends the sequence early, and reaching the end of the body also ends it. Repeating enumeration runs the iterator again, so its work and side effects may repeat. The interface `IEnumerable<T>` alone does not tell a caller whether a sequence is already stored or generated lazily. [S1, S2]

## Claims
- id: C1
  claim: "yield return supplies the next element."
  source: S1
  evidence: "to provide the next value in iteration"
- id: C2
  claim: "yield break ends iteration explicitly."
  source: S1
  evidence: "to explicitly signal the end of iteration"
- id: C3
  claim: "The iterator body starts when enumeration begins."
  source: S2
  evidence: "Calling an iterator method doesn't run its body immediately"

## Sources
- [S1] yield statement. Microsoft and .NET documentation contributors. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/yield. CC-BY-4.0; license: https://raw.githubusercontent.com/dotnet/docs/main/LICENSE. Accessed 2026-11-05.
- [S2] Iterators. Microsoft and .NET documentation contributors. https://learn.microsoft.com/en-us/dotnet/csharp/iterators. CC-BY-4.0; license: https://raw.githubusercontent.com/dotnet/docs/main/LICENSE. Accessed 2026-11-05.

## Attribution and notices
This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

Microsoft .NET documentation text is CC BY 4.0. This is an original condensed explanation. No source code is reproduced.
