New Iterator- Need help here Understanding its useage

Just as the subject line says

I dont really understand this .... my question is .... can someone demonstrate a simple usage and explain why this is a benefit to me
vbMarkOAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
I think Iterator is mainly used internally such as to implement the ForEach loops. I have never used it in my own code.
0
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
Iterators is a feature since .net 2.0. and simply use yield return which means that the current location in code is remembered to return each element one at a time.
here's a nice example from msdn:
http://msdn.microsoft.com/en-us/library/vstudio/dscyy5s0.aspx
0
 
vbMarkOAuthor Commented:
Yes I am familiar with the examples there including the animals one and so on ....

And I read the articles concerning it but Im just not wrapping my head around it ...

I mean why would I want the current location in code remembered?

I am sure I am over looking the obvious ... was just hoping someone could give an example of how n why I might use it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.