更新时间:2022-06-13 06:15:17
没有,有我不害怕。 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...)