Friday, April 25, 2014

Merging three array and take top 5 numbers using LINQ in C#

int[] _inputs1 = { 11,12, 13, 14, 15, 16, 17, 18, 169 };
int[] _inputs2 = { 11, 22, 33, 24, 25, 56, 67, 88, 99 };
int[] _inputs3 = { 1, 2, 3, 4, 5, 6, 7, 68, 98 };
Int32[] Concatenate=Input1.Concat(Input2).Concat(Input3).OrderByDescending(a=>a)
 .Take(5).ToArray();
foreach(int a in Concatenate)
{
 Console.writeline(a);
}

//output {168,99,98,88,68}
Share:

0 Comments:

Post a Comment