3 ms·
I found looking at the code that the C# compiler generates for its yield keyword to also be helpful for understanding this keyword. Source of an iterator examp
by MarkSweep 16y ago
I found looking at the code that the C# compiler generates for its yield keyword to also be helpful for understanding this keyword.
Source of an iterator example:
http://gist.github.com/524972 http://gist.github.com/524972
What the compiler generates for the above example:
http://gist.github.com/524974 http://gist.github.com/524974
The meat of it is in the MoveNext() function, where the original function is split up along the yield keywords into cases in a switch statement.