Click or drag to resize

CountDownExtensionCountDownT, TResult Method

Provides a countdown counter for a given count of elements at the tail of the sequence where zero always represents the last element, one represents the second-last element, two represents the third-last element and so on.

Namespace:  MoreLinq.Extensions
Assembly:  MoreLinq (in MoreLinq.dll) Version: 3.0.0
Syntax
public static IEnumerable<TResult> CountDown<T, TResult>(
	this IEnumerable<T> source,
	int count,
	Func<T, Nullable<int>, TResult> resultSelector
)

Parameters

source
Type: System.Collections.GenericIEnumerableT
The source sequence.
count
Type: SystemInt32
Count of tail elements of source to count down.
resultSelector
Type: SystemFuncT, NullableInt32, TResult
A function that receives the element and the current countdown value for the element and which returns those mapped to a result returned in the resulting sequence. For elements before the last count, the coundown value is null.

Type Parameters

T
The type of elements of source
TResult
The type of elements of the resulting sequence.

Return Value

Type: IEnumerableTResult
A sequence of results returned by resultSelector.

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 method uses deferred execution semantics and streams its results. At most, count elements of the source sequence may be buffered at any one time unless source is a collection or a list.
See Also