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

 

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 T>
[ExtensionAttribute]
static TAccumulate Aggregate(
	ImmutableArray<T> immutableArray,
	TAccumulate seed,
	Func<TAccumulate, T, TAccumulate>^ func
)

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.

Return Value

Type: TAccumulate

The final accumulator value.

Type Parameters

TAccumulate

The type of the accumulated value.

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: