tags:

views:

34

answers:

2

I have three string arrays. I want to combine them using zip in linq. How to do?

arr1.Zip(arr2, (a1, a2) => a1 + a2);

How to add arr3?

+1  A: 

You can use Zip again:

arr1.Zip(arr2, (a1, a2) => new { a1, a2 })
    .Zip(arr3, (a12, a3) => a12.a1 + a12.a2 + a3)

or

arr1.Zip(arr2, (a1, a2) => a1 + a2)
    .Zip(arr3, (a12, a3) => a12 + a3)

The former version avoids one extra string concatenation.

Jon Skeet
173K?? Is that 173 or 173,000? Looks like i can close my eyes and follow your suggestion superman :) Is that link i posted also containing the right answer?
As
@As: Yes, the link is doing basically the same as the second of my snippets.
Jon Skeet
A: 

Never mind. I found the answer here

Combine Multiple Sequences in LINQ using the Zip Operator - .NET 4.0

As