AggregateRightExtensionAggregateRightTSource(IEnumerableTSource, FuncTSource, TSource, TSource) Method

Applies a right-associative accumulator function over a sequence. This operator is the right-associative version of the AggregateTSource(IEnumerableTSource, FuncTSource, TSource, TSource) LINQ operator.

Definition

Namespace: MoreLinq.Extensions
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static TSource AggregateRight<TSource>(
	this IEnumerable<TSource> source,
	Func<TSource, TSource, TSource> func
)

Parameters

source  IEnumerableTSource
Source sequence.
func  FuncTSource, TSource, TSource
A right-associative accumulator function to be invoked on each element.

Type Parameters

TSource
The type of the elements of source.

Return Value

TSource
The final accumulator value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This operator executes immediately.

Example

C#
string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => $"({a}/{b})");
The result variable will contain "(1/(2/(3/(4/5))))".

See Also