Merge 2 arrays using LINQ
c#, data-structures, linq
Solution
You can do it using `Concat` and `ToArray`, like this:
var res = num1.Concat(num2).ToArray();
This will put all elements of `num2` after elements of `num1`, producing `res` that looks like
int[] { 1, 55, 89, 43, 67, -3, 11, 35, 79, 23, 7, -10 };
EDIT : (in response to a comment: "how can I also sort either allNumbers and res?")
Once your two arrays are merged, you can use `OrderBy` to sort the result, like this:
var res = num1.Concat(num2).OrderBy(v=>v).ToArray();
Problem
I have two simple array and I would like to merge using join linq: ``` int[] num1 = new int[] { 1, 55, 89, 43, 67, -3 }; int[] num2 = new int[] { 11, 35, 79, 23, 7, -10 }; var result = from n1 in num1 from n2 in num2 select result; ```