LinqExtensions.

Map<TSource, TResult>(IEnumerable<TSource>, Func<TSource, int, TResult>) Method

Summary

Projects each element of a sequence into a new form by incorporating the element's index.

Syntax

public static IEnumerable<TResult> Map<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, int, TResult> selector)

Type Parameters

Name Description
TSource The type of the elements of source.
TResult The type of the value returned by selector.

Parameters

Name Type Description
source IEnumerable<TSource> A sequence of values to invoke a transform function on.
selector Func<TSource, int, TResult> A transform function to apply to each source element; the second parameter of the function represents the index of the source element.

Return Value

Type Description
IEnumerable<TResult> An System.Collections.Generic.IEnumerable`1 whose elements are the result of invoking the transform function on each element of source.