Map2
Builds a new collection whose elements are the results of applying the given mapping
function to the corresponding elements of the two collections pairwise.
Parameters
Returns
Func<T, T2, TResult> mapping
IEnumerable<T> source
IEnumerable<T2> source2
IEnumerable<TResult>
Usage
Multiplying the sum of each pair of values by two
//IEnumerable<int> source = { 1, 2, 3, 4, 5 }
//IEnumerable<int> source2 = { 5, 3, 3, 3, 0 }
IEnumerable<int> result =
source.Map2(
source2,
(value1, value2) => (value1 + value2) * 2);
//result = { 12, 10, 12, 14, 0}
Last updated
Was this helpful?