How to use order by descending with Linq in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        string[] arr = { "c#", "vb.net", "c", "php", "c++", "java" };

        var result = from s in arr
                        orderby s descending
                        select s;

        foreach (string w in result)
            Console.WriteLine(w);
        }
}





/*
run:

vb.net
php
java
c++
c#
c

*/

 



answered Jan 4, 2023 by avibootz

Related questions

...