The c# “yield” keyword explained

I’ve been trying to understand the “yield” keyword and it’s a tough one for me to wrap my mind around. 

…it doesn’t really end the method’s execution. yield return pauses the method execution and the next time you call it (for the next enumeration value), the method will continue to execute from the last yield return call. It sounds a bit confusing I think… (ShayF)

I found a few good resources on it:

Struggles by Lars C.

Give way to the yield keyword! (IronShay)

Advertisements