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

 

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

Parameters

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

The collection to apply the function to.

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

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

Return Value

Type: T

The final value after the cumulative function has been applied to all elements.

Type Parameters

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: