Multiple choice technology programming languages

Which C# Keyword Signals To The Compiler That The Method In Which It Appears Is An Iterator Block?

  1. Signal

  2. Yield

  3. Iterator

  4. sealed

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The yield keyword in C# signals the compiler that the method is an iterator block. It enables lazy evaluation by returning elements one at a time when requested, rather than building the entire collection first. This is essential for implementing custom iterators with IEnumerable.