LinqExtensions.

Filter<TSource>(IEnumerable<TSource>, Func<TSource, int, bool>) Method

Summary

Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

Syntax

public static IEnumerable<TSource> Filter<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate)

Type Parameters

Name Description
TSource The type of the elements of source.

Parameters

Name Type Description
source IEnumerable<TSource> An System.Collections.Generic.IEnumerable`1 to filter.
predicate Func<TSource, int, bool> A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

Return Value

Type Description
IEnumerable<TSource> An System.Collections.Generic.IEnumerable`1 that contains elements from the input sequence that satisfy the condition.