Yield Return
noun
say it: “YEELD rih-TURN” /jiːld rɪˈtɜːrn/
A C# statement that hands back the next value from an iterator method, one at a time.
What is Yield Return in C#?
Yield Return — A statement that produces the next value from an iterator without building the whole sequence first.
class Countdown
{
IEnumerable<int> Numbers()
{
yield return 3;
yield return 2;
yield return 1;
}
}
In a sentence
- “The method uses yield return to hand out one page number at a time.”
Level: Freelancer · More C# terms at this level
Updated