LINQ concatenates elements in two-line arrays

I have two string arrays

Array1 = {"Paul","John","Mary"}
Array2 = {"12","13","15"}

I would like to know if it is possible to join these arrays so that the resulting arrays have something like

{"Paul12","John13","Mary15"}
+3
source share
2 answers
 var Array3 = Array1.Zip(Array2, (a, b) => a + b).ToList();
+8
source

You can use Zip.

var array1 = new[] {"Paul", "John", "Mary"};
var array2 = new[] {"12", "13", "15"};

var result = array1.Zip(array2, (a1, a2) => String.Concat(a1, a2)).ToArray();
+6
source

All Articles