As per the MSDN 'Linq` is
Let’s consider the following example.
Now you want to create a collection which has the full name like
In this scenario, we can use the
Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language.LINQ provides a lot of operator out of the box. There is one operator, which is lesser-known. In this article, I will show how and where to use the LINQ
Zip
operatorZip
the operator is used when you want to iterates multiple collections at the same time.Let’s consider the following example.
var firstNames = new string[] { "John", "Bill", "Tim", "Santosh" };
var lastNames = new String[] { "Doe", "Gates", "Sanders", "Singh" };
We have two collections of string, the first list have the firstName of the person and the second list have lastName of the person.Now you want to create a collection which has the full name like
John Doe
,Bill Gates
etc.In this scenario, we can use the
zip
operator.var fullName=firstNames.Zip(lastNames,(f,l)=> f +" "+l);