Click or drag to resize
MoreEnumerableTakeEveryTSource Method
Returns every N-th element of a sequence.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 2.1.0
Syntax
public static IEnumerable<TSource> TakeEvery<TSource>(
	this IEnumerable<TSource> source,
	int step
)

Parameters

source
Type: System.Collections.GenericIEnumerableTSource
Source sequence
step
Type: SystemInt32
Number of elements to bypass before returning the next element.

Type Parameters

TSource
Type of the source sequence

Return Value

Type: IEnumerableTSource
A sequence with every N-th element of the input sequence.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. 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 deferred execution and streams its results.
Examples
int[] numbers = { 1, 2, 3, 4, 5 };
IEnumerable<int> result = numbers.TakeEvery(2);
The result variable, when iterated over, will yield 1, 3 and 5, in turn.
See Also