Answer:
It performs ITERATION .
When we use the yield keyword in a statement, we indicate that the method, operator, or get accessor in which it appears is an iterator.
It creates a state machine "under the covers" that remembers where you were on each additional cycle of the function and picks up from there. In short,Yield has two great uses
a) It helps to provide custom iteration with out creating temp collections.
b) It helps to do stateful iteration.
Asked In: Many Interviews |
Alert Moderator