Open sandboxFocus

Method SelectRecursive

SelectRecursive<T>(T, Func<T, T?>)

Selects a sequence by recursively applying a function to get the next item, starting from a single initial item.

Declaration
public static IEnumerable<T> SelectRecursive<T>(T item, Func<T, T?> getNext) where T : class, ICompilationElement
Parameters
Type Name Description
T item

The initial item.

Func<T, T> getNext

A function that returns the next item in the sequence, or null to end the sequence.

Returns
Type Description
IEnumerable<T>

An enumerable sequence starting with item and continuing with items returned by getNext.

Type Parameters
Name Description
T

The type of compilation element.

SelectRecursive<T>(IEnumerable<T>, Func<T, T?>)

Selects a sequence by recursively applying a function to get the next item, for each item in a collection.

Declaration
public static IEnumerable<T> SelectRecursive<T>(this IEnumerable<T> items, Func<T, T?> getNext) where T : class, ICompilationElement
Parameters
Type Name Description
IEnumerable<T> items

The initial collection of items.

Func<T, T> getNext

A function that returns the next item in the sequence, or null to end the sequence for that item.

Returns
Type Description
IEnumerable<T>

An enumerable sequence containing all items and their descendants obtained by recursively applying getNext.

Type Parameters
Name Description
T

The type of compilation element.