Answer: yield is the contextual keyword of
C# which is used as an iterator. By using this keyword, there is no need to have an explit extra class when we deal with
IEnumerable and
IEnumarator patterns.
yield actually interacts with the
foreach loop.
Example,
yield return someVar; // returning expression someVar
Asked In: Spotted While Learning |
Alert Moderator