FoldExtensionFoldT, TResult(IEnumerableT, FuncT, T, T, TResult) Method

Returns the result of applying a function to a sequence of 3 elements.

Definition

Namespace: MoreLinq.Extensions
Assembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
C#
public static TResult Fold<T, TResult>(
	this IEnumerable<T> source,
	Func<T, T, T, TResult> folder
)

Parameters

source  IEnumerableT
The sequence of items to fold.
folder  FuncT, T, T, TResult
Function to apply to the elements in the sequence.

Type Parameters

T
Type of element in the source sequence.
TResult
Type of the result.

Return Value

TResult
The folded value returned by folder.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. 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 uses immediate execution and effectively buffers as many items of the source sequence as necessary.

Exceptions

ArgumentNullException Either source or folder is .
InvalidOperationExceptionsource does not contain exactly 3 elements.

See Also