1

Say I have two sets

var Set1 = new[] { "A", "B", "C" };
var Set2 = new[] { "1", "2", "3" };

To concat these two sets usually i do

foreach (string itm1 in Set1 )
{
     foreach (string itm2 in Set2)
     {
         Console.WriteLine(itm1 + itm2);
     }
}

Is there any LINQ style of getting the same result?

4

2 に答える 2

0

試す

 var concatSet =Set1
                .SelectMany(
                             item => Set2,
                             (i1, i2) => (i1 + i2)
                           );
于 2013-06-23T17:49:53.440 に答える