Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

iterator

A method that hands back items one at a time, pausing between them.

An iterator is a method using yield return whose body the compiler turns into an enumerator that resumes where it left off on each MoveNext call.

Loading interactive…

Examples

  • static IEnumerable<int> Evens() { for (int i = 0; ; i += 2) yield return i; } hands out even numbers one at a time, for as long as you ask.

Read the full section →