How to join two Lists in linq?

It sounds like you're trying to "join" these in a pairwise fashion by index: the first element from each list, then the second element etc. That suggests you want Zip which was introduced in . NET 4: var zipped = list1. Zip(list2, (x1, x2) => x1 + x2) If you're using .

NET 3.5, you can use a separate implementation of the same method, such as the one in MoreLINQ EDIT: Alternatively, Eric Lippert posted some source code for Zip a while ago, too.

It sounds like you're trying to "join" these in a pairwise fashion by index: the first element from each list, then the second element etc. That suggests you want Zip, which was introduced in . NET 4: var zipped = list1. Zip(list2, (x1, x2) => x1 + x2); If you're using .

NET 3.5, you can use a separate implementation of the same method, such as the one in MoreLINQ. EDIT: Alternatively, Eric Lippert posted some source code for Zip a while ago, too.

Is it possible to implement in visual studio 2008 express edition – ratty Dec 13 '10 at 13:30 @ratty: Yes, see my last paragraph. Basically grab the implementation from MoreLINQ. – Jon Skeet Dec 13 '10 at 13:31 skeet sorry for disturb how use that more linq in my visual studio 2008 – ratty Dec 13 '10 at 13:33 @ratty: You could take the source code for Zip.Cs (code.google.

Com/p/morelinq/source/browse/trunk/MoreLinq/…) and just include it in your project or download the whole of MoreLINQ and build it as a class library. Or use Eric Lippert's version. – Jon Skeet Dec 13 '10 at 13:34.

1 Or in general - IEnumerable.Join(). – Femaref Dec 13 '10 at 13:12 1 I don't think he's actually after Join here, based on the example in the question. See my answer for my interpretation.

– Jon Skeet Dec 13 '10 at 13:16 I had no idea such a method Zip even existed...will have to investigate. – Jon Preece Dec 13 '10 at 13:22 @Femaref: To be picky, it's Enumerable.Join(), which is an extension method for IEnumerable – VVS Dec 13 '10 at 13:24.

Try Joining them together weblogs.asp.net/rajbk/archive/2010/03/12... msdn.microsoft.com/en-us/library/bb39767....

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 of the program --- 7 9 11 13 15.

Python join, why is it string. Join(list) instead of list. Join(string)?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions