What does the yield return statement do in a C# method?
Correct answer C. It returns one element of an iterator and resumes from that point on the next request
Explanation
A method containing yield return is an iterator returning IEnumerable or IEnumerator. The compiler turns it into a state machine: each time the consumer asks for the next item, execution resumes after the last yield return. Items are produced lazily, so sequences can be infinite. yield break ends the iteration.
Answer checked How we write and check questions
Discussion