Returns every N-th element of a source sequence.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<TSource> TakeEvery<TSource>( this IEnumerable<TSource> source, int step )
<ExtensionAttribute> _ Public Shared Function TakeEvery(Of TSource) ( _ source As IEnumerable(Of TSource), _ step As Integer _ ) As IEnumerable(Of TSource)
public: [ExtensionAttribute] generic<typename TSource> static IEnumerable<TSource>^ TakeEvery( IEnumerable<TSource>^ source, int step )
Generic Template Parameters
- TSource
- Type of the source sequence
Parameters
- source (IEnumerable<(Of <(<'TSource>)>)>)
- Source sequence
- step (Int32)
- Number of elements to bypass before returning the next element.
Return Value
[Missing <returns> documentation for "M:MoreLinq.MoreEnumerable.TakeEvery``1(System.Collections.Generic.IEnumerable{``0},System.Int32)"]
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TSource>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Remarks
This operator uses deferred execution and streams its results.
Examples
Copy | |
---|---|
int[] numbers = { 1, 2, 3, 4, 5 }; IEnumerable<int> result = numbers.TakeEvery(2); |
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)