ImmutableArrayExtensions::Aggregate<TAccumulate, TResult, T> Method (ImmutableArray<T>, TAccumulate, Func<TAccumulate, T, TAccumulate>^, Func<TAccumulate, TResult>^)

 

Applies a function to a sequence of elements in a cumulative way.

Namespace:   System.Linq
Assembly:  System.Collections.Immutable (in System.Collections.Immutable.dll)

public:
generic<typename TAccumulate, typename TResult, typename T>
[ExtensionAttribute]
static TResult Aggregate(
	ImmutableArray<T> immutableArray,
	TAccumulate seed,
	Func<TAccumulate, T, TAccumulate>^ func,
	Func<TAccumulate, TResult>^ resultSelector
)

Parameters

immutableArray
Type: System.Collections.Immutable::ImmutableArray<T>

The collection to apply the function to.

seed
Type: TAccumulate

The initial accumulator value.

func
Type: System::Func<TAccumulate, T, TAccumulate>^

A function to be invoked on each element, in a cumulative way.

resultSelector
Type: System::Func<TAccumulate, TResult>^

Return Value

Type: TResult

The final accumulator value.

Type Parameters

TAccumulate

The type of the accumulated value.

TResult

The type of result returned by the result selector.

T

The type of element contained by the collection.

Aggregate<T> method makes it simple to perform a calculation over a sequence of values. This method works by calling func one time for each element in source. Each time func is called, Aggregate<T> passes both the element from the sequence and an aggregated value (as the first argument to func). The value of the seed parameter is used as the initial aggregate value. The result of func replaces the previous aggregated value. Aggregate<T> returns the final result of func.

Return to top
Show: