WARNING: 2 Killer C# Iterator Bugs (And How To Prevent Them)
December 27, 2023
• 522 views
ienumerablemicrosoft mvpenumeratorforeach ienumerable c#foreach ienumerablec# enumerable foreachforeach c#ienumeratoryield c#how do enumerables workforeachenumerablec# foreachc# ienumerable foreachc# iterationienumerable vs ienumeratorienumerable vs ilistc# iteratoriterator pattern c#iterator design patternc# yield returnc# yielditerator patternyield keywordc# iteratorsienumerable tutorialdotnetdesign patternscsharpAPIsAPI
C# iterators are a powerful feature that leverage IEnumerable in C# as well as the yield return syntax. Iterators are lazily evaluated which can be really useful - but it can also be incredibly problematic.
In this video, I'll walk through 2 scenarios that will make you think twice when you go to use the yield keyword in C# alongside your IEnumerable! Hopefully this will save you some headaches!
Have you subscribed to my weekly newsletter yet? A 5-minute read every weekend, right to your inbox...
