Dev2.TreeEx.Descendants C# (CSharp) Method

Descendants() public static method

public static Descendants ( this root ) : IEnumerable
root this
return IEnumerable
        public static IEnumerable<IExplorerItemModel> Descendants(this IExplorerItemModel root)
        {
            var nodes = new Stack<IExplorerItemModel>(new[] { root });
            while(nodes.Any())
            {
                IExplorerItemModel node = nodes.Pop();
                yield return node;
                foreach(var n in node.Children) nodes.Push(n);
            }
        }