Zip
In this chapter you will learn:
Get to know Zip operator
The Zip
operator enumerates two sequences returns a
sequence based on applying a function over each element pair.
using System;/*from j ava2 s . c o m*/
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] numbers = { 3, 5, 7 };
string[] words = { "three", "five", "seven", "ignored" };
IEnumerable<string> zip = numbers.Zip(words, (n, w) => n + "=" + w);
foreach (string i in zip)
{
Console.WriteLine(i);
}
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » Linq Operators