Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to zip 4 lists, i manage to do it with 3 of them, but if there is more? How?

What I have tried:

<pre>IEnumerable<Tuple<string, string, string,string>> CollapedList = list1
           .Zip(list2, (e1, e2) => new { e1, e2 })
           .Zip(list3, (z1, e3) => Tuple.Create(z1.e1, z1.e2, e3))
            .Zip(list4, (z2, e4) => Tuple.Create(z2.z1.e1, z2.z1.e2, z2.e3, e4));
Posted
Updated 8-Sep-20 3:17am
v2
Comments
BillWoodruff 10-Sep-20 0:06am    
lists of what ? show the structure of 'list1, etc.

1 solution

The documentation (Tuple types - C# reference | Microsoft Docs[^]) shows how to make tuples with more elements.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900