implementing a state machine using the "yield" keyword

Posted by Matt Warren on Stack Overflow See other posts from Stack Overflow or by Matt Warren
Published on 2009-07-28T15:19:00Z Indexed on 2010/04/08 0:23 UTC
Read the original article Hit count: 449

Filed under:
|
|
|

Is it feasible to use the yield keyword to implement a simple state machine as shown here. To me it looks like the C# compiler has done the hard work for you as it internally implements a state machine to make the yield statement work.

Can you piggy-back on top of the work the compiler is already doing and get it to implement most of the state machine for you?

Has anyone done this, is it technically possible?

© Stack Overflow or respective owner

Related posts about c#

Related posts about yield