Click or drag to resize

XEnumerableFlattenTNode, TResult Method (IEnumerableTNode, FuncTNode, IEnumerableTNode, TreeTraversalMode, FuncTNode, TResult)

Returns a flattened sequence from a graph or hierarchy of elements, using the specified children selector, and in the specified traversal order.

Namespace:  Linq.Extras
Assembly:  Linq.Extras (in Linq.Extras.dll) Version: 5.0.0+96a4f4bfed64095342c5df107c1fe1fb95603ee5
Syntax
public static IEnumerable<TResult> Flatten<TNode, TResult>(
	this IEnumerable<TNode> source,
	Func<TNode, IEnumerable<TNode>> childrenSelector,
	TreeTraversalMode traversalMode,
	Func<TNode, TResult> resultSelector
)

Parameters

source
Type: System.Collections.GenericIEnumerableTNode
The source hierarchy to flatten.
childrenSelector
Type: SystemFuncTNode, IEnumerableTNode
The delegate used to retrieve the children of an element.
traversalMode
Type: Linq.ExtrasTreeTraversalMode
The traversal order.
resultSelector
Type: SystemFuncTNode, TResult
The delegate used to project each node of the hierarchy to a result element. It accepts the node as a paramater.

Type Parameters

TNode
The type of the elements in the source hierarchy.
TResult
The type of the elements in the output sequence.

Return Value

Type: IEnumerableTResult
A flat sequence of elements produced from the elements in the source hierarchy.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTNode. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also