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 would like to do:
IEnumerable<string> SomeRecursiveMethod() { // some code // ... yield return SomeRecursiveMethod(); } Naturally this results in an error, which can be resolved by doing a simple loop. Is there a better way to do this? A loop feels a bit clunky.
ForEachextension method forIEnumerable<T>. See the accepted answer for this question: stackoverflow.com/questions/200574. Unfortunately, it seems you can'tyield returnfrom a lambda...