Skip to content

M_CodeJam_Collections_EnumerableExtensions_AggregateOrDefault__1

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

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

Applies an accumulator function over a sequence.

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

Syntax

C#

public static TSource AggregateOrDefault<TSource>(
	this IEnumerable<TSource> source,
	Func<TSource, TSource, TSource> func,
	Func<TSource> defaultSelector
)

VB

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

F#

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

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(TSource)
An IEnumerable(T) to aggregate over.
func
Type: System.Func(TSource, TSource, TSource)
An accumulator function to be invoked on each element.
defaultSelector
Type: System.Func(TSource)
A function to select default value if the source is empty.

Type Parameters

 

TSource
The type of the elements of source.

Return Value

Type: 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 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