Performance of nested yield in a tree

前端 未结 5 577
既然无缘
既然无缘 2020-11-28 12:20

I\'ve got a tree-like structure. Each element in this structure should be able to return a Enumerable of all elements it is root to. Let\'s call this method IEnumerabl

5条回答
  •  -上瘾入骨i
    2020-11-28 12:46

    According to my prior experiences using yield is a lot more effective than creating a List. If you're using .NET 3.5, this implementation should be fine. But don't forget the

    yield break;
    

    At the end. :-)

提交回复
热议问题