C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
And: The second argument to the Zip method is a lambda expression that describes a Func instance.
Arguments: Two integer parameters are the arguments to the Func, and the return value is the 2 parameters added together.
Int, uintReturnC# program that uses Zip extension method
using System;
using System.Linq;
class Program
{
static void Main()
{
// Two source arrays.
var array1 = new int[] { 1, 2, 3, 4, 5 };
var array2 = new int[] { 6, 7, 8, 9, 10 };
// Add elements at each position together.
var zip = array1.Zip(array2, (a, b) => (a + b));
// Look at results.
foreach (var value in zip)
{
Console.WriteLine(value);
}
}
}
Output
7
9
11
13
15
Tip: Zip will not throw an exception if the two collections are of unequal length.