Recursion with yield return elements order in tree

前端 未结 3 606
挽巷
挽巷 2021-01-02 06:24

I have a recursive function that returns all subtree nodes, given the starting root node.

private IEnumerable getAllNodesRecursively(Node subnode         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-02 06:46

    Yes it's possible, just put the yield return before the foreach. You are thinking of the behaviour of a normal return statement.

提交回复
热议问题