I use the yield return
keyword quite a bit, but I find it lacking when I want to add a range to the IEnumerable
. Here\'s a quick example of what I
The yield keyword is indeed very nice. But nesting it in a for loop will cause more glue code to be generated and executed.
If you can live with a less functional style of programming, you can pass a List around to which you append:
void GenerateList(List result)
{
result.Add("something")
// more code.
GenerateList(result);
}