The Yield Statement in C#(alteridem.net)

submitted by rprouserprouse(1175) 4 years, 5 months ago

The yield statement is another often overlooked keyword that was introduced in .NET 2.0. It is used to return items from a loop within a method and retain the state of the method through multiple calls.

2 comments |category: |Views: 124

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by senfosenfo(881) 4 years, 5 months ago 0

This is a useful article and I honestly didn't know about yield break, but two better articles (in my opinion) are:

http://msdn2.microsoft.com/en-us/vcsharp/bb264519.aspx
http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx

Reply

posted by lcorneliussenlcorneliussen(490) 3 years, 8 months ago 0

If you're interested in how the yield keyword actually works, read this:

http://startbigthinksmall.wordpress.com/2008/06/09/behind-the-scenes-of-the-c-yield-keyword/

Reply

information Login or create an account to comment on this story