Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq Compound selection

How can i combine two arrays in to a single array during compound selection ( without using Union ) ( The question was asked at interview).

    var num1 = new int[] { 12, 3, 4, 5 };
    var num2 = new int[] { 1, 33, 6, 10 };

I tried as

    var pairs = from a in num1 from b in num2  select new {combined={a,b}};

Expected: combined need to be {12,3,4,5,1,33,6,10}

like image 672
user190560 Avatar asked Mar 12 '26 12:03

user190560


1 Answers

num1.Concat( num2 );

I'm not sure if there is a related LINQ keyword.

like image 161
Tinister Avatar answered Mar 15 '26 01:03

Tinister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!