且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#,回报率范围内/集合

更新时间:2022-04-12 22:18:31

没有,没有,我害怕。 F#的确实的与支持这一产量,但在C#中没有等效 - 你必须使用循环,基本上是这样。对不起......我觉得你的痛苦。我在提到它我Edulinq博客文章之一,它会做的事情更简单。

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.

请注意,使用收益回报递归可能是昂贵的 - 看到的韦斯·戴尔对迭代器了解更多信息(并提到了收益率的foreach四年前是正在考虑...)后

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...)