C#: yield return range/collection

No, there isn’t I’m afraid. F# does support this with yield!, but there’s no equivalent in C# – you have to use the loop, basically. Sorry… I feel your pain. I mentioned it in one of my Edulinq blog posts, where it would have made things simpler.

Note that using yield return recursively can be expensive – see Wes Dyer’s post on iterators for more information (and mentioning a “yield foreach” which was under consideration four years ago…)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)