I have List<Product[]>
and I need to join them into one Product[]
.
CSharp Online Training var myList = new List<int>(); myList. AddRange(arr1); myList. AddRange(arr2); Use the AddRange() method the arrays into the newly created list.
LINQ allows us to write query against all data whether it comes from array, database, XML etc.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With