2 using System
.Collections
.Generic
;
4 namespace IEnumerableExtras
7 /// <see cref="IEnumerable{T}"/> map extension.
9 public static class EnumerableMap
12 /// Produce new instance of <see cref="IEnumerable{TResult}"/> by applying
13 /// predicate to each element in this instance of <see cref="IEnumerable{T}"/>.
15 /// <typeparam name="T">This collection's item type.</typeparam>
16 /// <typeparam name="TResult">Resulting collection item type.</typeparam>
17 /// <param name="collection">This instance of <see cref="IEnumerable{T}"/>.</param>
18 /// <param name="predicate">Function returnting objects of type <typeparamref name="TResult"/> based on objects of type <typeparamref name="T"/>.</param>
19 /// <returns></returns>
20 public static IEnumerable
<TResult
> Map
< T
, TResult
>( this IEnumerable
<T
> collection
, Func
<T
, TResult
> predicate
)
22 foreach ( var item
in collection
)
24 yield return predicate( item
);