Sorting the number using Linq in C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Test_Application
{
public class Program
{
static void Main(string[] args)
{
int[] a = new int[] { 3, 8, 5, 9, 2, 0, 1 };
var k = from i in a //
orderby i descending // LINQ Code
select i; //
foreach (int j in k)
{
Console.WriteLine(j);
}
Console.ReadLine();
}
}
}
Output : 9 8 5 3 2 1 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Test_Application
{
public class Program
{
static void Main(string[] args)
{
int[] a = new int[] { 3, 8, 5, 9, 2, 0, 1 };
var k = from i in a //
orderby i descending // LINQ Code
select i; //
foreach (int j in k)
{
Console.WriteLine(j);
}
Console.ReadLine();
}
}
}
Output : 9 8 5 3 2 1 0