MoreEnumerable.CountDown<T, 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: MoreLinqAssembly: MoreLinq (in MoreLinq.dll) Version: 4.0.0+092a40d82a1b280568ffa006d9a210bdec0792cd
public static IEnumerable<TResult> CountDown<T, TResult>(
this IEnumerable<T> source,
int count,
Func<T, int?, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function CountDown(Of T, TResult) (
source As IEnumerable(Of T),
count As Integer,
resultSelector As Func(Of T, Integer?, TResult)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename T, typename TResult>
static IEnumerable<TResult>^ CountDown(
IEnumerable<T>^ source,
int count,
Func<T, Nullable<int>, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member CountDown :
source : IEnumerable<'T> *
count : int *
resultSelector : Func<'T, Nullable<int>, 'TResult> -> IEnumerable<'TResult>
- source IEnumerable<T>
- The source sequence.
- count Int32
- Count of tail elements of
source to count down.
- resultSelector Func<T, Nullable<Int32>, 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 countdown value is
null.
- T
-
The type of elements of source
- TResult
-
The type of elements of the resulting sequence.
IEnumerable<TResult>
A sequence of results returned by
resultSelector.In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerable<T>. 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).
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.