Thursday, February 10, 2011

Linq join several arrays

 I have List<Product[]> and I need to join them in Product[] from it.
  • You can use SelectMany and then ToArray to do this.

    var result = source.SelectMany(i => i).ToArray();
    
  • You can use .Concat() extension method as well, and then .ToArray(): x.Concat(y).Concat(z).ToArray();

    From Ravadre

0 comments:

Post a Comment