OrderBy Descending in CSharp

Description

The following code shows how to orderBy Descending.

Example


//  w  ww. j a va 2  s  .c o m
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        double[] doubles = { 1.7, 2.3, 1.9, 4.1, 2.9 };

        var sortedDoubles =
            from d in doubles
            orderby d descending
            select d;

        Console.WriteLine("The doubles from highest to lowest:");
        foreach (var d in sortedDoubles) {
            Console.WriteLine(d);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ