Skip to content

Node<TNode>.Traverse.DepthFirstPreOrder Method ​

Definition ​

Enumerates over a node and its descendants depth first, pre-order.

c#
public static IEnumerable<TNode> DepthFirstPreOrder(TNode root, bool includeRoot = true, Func<TNode, bool>? shouldEnumerateDescendants = null);

View source

Parameters ​

NameTypeDescription
rootTNodeThe root node to enumerate over.
includeRootBooleanWhether to include root in the results or not. Defaults to true.
shouldEnumerateDescendantsFunc<TNode, Boolean>Optional function to specify whether the descendants of a given node should be included or not. If not provided then all descendants will be included.

Returns ​

IEnumerable<TNode>

A lazy IEnumerable<T> of the descendants in depth first pre-order.