1.

How to sort array using LINQ

Answer»

Below program first create INT array and then apply QUERY on that array and sort with the help of linq
using System;
using System.Linq;
class SortArrayLinqProgram
{
STATIC void Main()
{
int[] array1 = { 5, 4, 1, 2, 3 };
var query = from element in array1
orderby element
select element;
int[] array2 = query.ToArray();
foreach (int value in array2)
{
Console.WriteLine(value);
}
}
}



Discussion

No Comment Found