Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

EnumerableExtensions.Flatten<T>(IEnumerable<T>, Func<T, IEnumerable<T>>) Method

Converts a hierarchical data structure into a flat collection. This method traverses the hierarchy defined by the getItems() function. The function accepts all hierarchy items and returns nested items as a flat collection.

Namespace: DevExpress.Maui.Mvvm

Assembly: DevExpress.Maui.Mvvm.dll

NuGet Package: DevExpress.Maui.Mvvm

#Declaration

C#
public static IEnumerable<T> Flatten<T>(
    this IEnumerable<T> source,
    Func<T, IEnumerable<T>> getItems
)

#Parameters

Name Type Description
source IEnumerable<T>

The source collection that contains the root items of the hierarchical data structure.

getItems Func<T, IEnumerable<T>>

The function that invokes for each item in the source collection and retrieves nested items.

#Type Parameters

Name Description
T

The type of items stored in the source collection.

#Returns

Type Description
IEnumerable<T>

The flat collection of items.

See Also