AggregateRightExtension.AggregateRight<TSource> Method (IEnumerable<TSource>, Func<TSource, TSource, TSource>) |
Applies a right-associative accumulator function over a sequence.
This operator is the right-associative version of the
Aggregate<TSource> (IEnumerable<TSource> , Func<TSource, TSource, TSource> ) LINQ operator.
Namespace:
MoreLinq.Extensions
Assembly:
MoreLinq (in MoreLinq.dll) Version: 3.3.1+b77df70598ab84c28cd43dcf74594024b6d575e1
Syntaxpublic static TSource AggregateRight<TSource>(
this IEnumerable<TSource> source,
Func<TSource, TSource, TSource> func
)
<ExtensionAttribute>
Public Shared Function AggregateRight(Of TSource) (
source As IEnumerable(Of TSource),
func As Func(Of TSource, TSource, TSource)
) As TSource
public:
[ExtensionAttribute]
generic<typename TSource>
static TSource AggregateRight(
IEnumerable<TSource>^ source,
Func<TSource, TSource, TSource>^ func
)
[<ExtensionAttribute>]
static member AggregateRight :
source : IEnumerable<'TSource> *
func : Func<'TSource, 'TSource, 'TSource> -> 'TSource
Parameters
- source
- Type: System.Collections.Generic.IEnumerable<TSource>
Source sequence. - func
- Type: System.Func<TSource, 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
Type:
TSourceThe final accumulator value.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerable<TSource>. 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.
Examplesstring result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => string.Format("({0}/{1})", a, b));
The
result variable will contain
"(1/(2/(3/(4/5))))".
See Also