Lecture overview -- Keyboard shortcut: 'u'  Previous page: Making iterators with yield return -- Keyboard shortcut: 'p'    Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Collection Classes - slide 36 : 36

Iterator blocks and yield return
Iterators are implemented by methods made with iterator blocks
IEnumerator<Type> Method() { // iterator block
  Type t;

  ...
  yield return t;
  ...
}
The compiler transforms a method with an iterator block to an underlying state machine which manages the traversal
Go to exercise
Infinite Collections of Integers