In C#, what do you mean by 'yield' keyword?

 Posted by Goud.Kv on 9/29/2014 | Category: C# Interview questions | Views: 1887 | Points: 40

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.

yield return someVar; // returning expression someVar

Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response