How to order an ArrayList in descending order with C#

1 Answer

0 votes
using System;
using System.Collections;
  
class Program
{
    static void Main() {
        ArrayList al = new ArrayList();
         
        al.Add("c#");
        al.Add("c");
        al.Add("php");
        al.Add("java");
        al.Add("c++");
        al.Add("python");
 
        al.Sort();
        al.Reverse();
        
        foreach (object item in al) {
            Console.WriteLine(item);
        }
    }
}
  
  
  
  
/*
run:
  
python
php
java
c++
c#
c
  
*/

 



answered Sep 5, 2023 by avibootz

Related questions

1 answer 133 views
1 answer 164 views
1 answer 205 views
1 answer 165 views
1 answer 128 views
2 answers 182 views
...