Search This Blog

Tuesday, September 6, 2016

LINQ OrderByDescending Example C#

C# > LINQ > Enumerable Class > OrderByDescending

Sorts the elements of a sequence in descending order.

Example

List<int> list = new List<int> {    2, 5 ,3 ,10, 7 };
IEnumerable<int> ordList = list.OrderByDescending(num => num);

foreach (int num in ordList)
{
Console.WriteLine(num);

}