How to sort string array in reverse alphabetic order (descending) with C#

1 Answer

0 votes
using System;
using System.Linq;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr = new string[] { "python", "java", "php", "c", "c++", "c#" };

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

            foreach (string str in desc) {
                Console.WriteLine(str);
            }
        }
    }
}


/*
run:
      
python
php
java
c++
c#
c
  
*/

 



answered Aug 6, 2018 by avibootz

Related questions

1 answer 164 views
1 answer 125 views
1 answer 127 views
2 answers 182 views
3 answers 281 views
...