Skip to content

M_CodeJam_Collections_EnumerableExtensions_AggregateOrDefault__3

Andrew Koryavchenko edited this page Jun 17, 2018 · 5 revisions

EnumerableExtensions.AggregateOrDefault(TSource, TAccumulate, TResult) Method (IEnumerable(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate), Func(TAccumulate, TResult), Func(TResult))

Applies an accumulator function over a sequence.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static TResult AggregateOrDefault<TSource, TAccumulate, TResult>(
	this IEnumerable<TSource> source,
	TAccumulate seed,
	Func<TAccumulate, TSource, TAccumulate> func,
	Func<TAccumulate, TResult> resultSelector,
	Func<TResult> defaultSelector
)

VB

<ExtensionAttribute>
Public Shared Function AggregateOrDefault(Of TSource, TAccumulate, TResult) ( 
	source As IEnumerable(Of TSource),
	seed As TAccumulate,
	func As Func(Of TAccumulate, TSource, TAccumulate),
	resultSelector As Func(Of TAccumulate, TResult),
	defaultSelector As Func(Of TResult)
) As TResult

F#

[<ExtensionAttribute>]
static member AggregateOrDefault : 
        source : IEnumerable<'TSource> * 
        seed : 'TAccumulate * 
        func : Func<'TAccumulate, 'TSource, 'TAccumulate> * 
        resultSelector : Func<'TAccumulate, 'TResult> * 
        defaultSelector : Func<'TResult> -> 'TResult 

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) to aggregate over.
seed
Type: TAccumulate
The initial accumulator value.
func
Type: System.Func(TAccumulate, TSource, TAccumulate)
An accumulator function to be invoked on each element.
resultSelector
Type: System.Func(TAccumulate, TResult)
A function to transform the final accumulator value into the result value.
defaultSelector
Type: System.Func(TResult)
A function to select default value if the source is empty.

Type Parameters

 

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.
TResult
The type of the resulting value.

Return Value

Type: TResult
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 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).

See Also

Reference

EnumerableExtensions Class
AggregateOrDefault Overload
CodeJam.Collections Namespace

Clone this wiki locally