Some help understanding “yield”
In my everlasting quest to suck less I'm trying to understand the "yield" statement, but I keep encountering the same error. The body of [someMethod] cannot be an iterator block because 'System.Collections.Generic.List< AClass>' is not an iterator interface type. This is the code where I got stuck: foreach (XElement header in headersXml.Root.Elements()){ yield return (ParseHeader(header)); } What am I doing wrong? Can't I use yield in an iterator? Then what's the point? In this example it said that List<ProductMixHeader> is not an iterator interface type. ProductMixHeader is a custom class,