How to get the index of last occurrence of element in ArrayList with C#

1 Answer

0 votes
using System;
using System.Collections;
      
class Program
{
    static void Main() {
        ArrayList al = new ArrayList();
             
        al.Add("java");
        al.Add("c#");
        al.Add("python");
        al.Add("c");
        al.Add("php");
        al.Add("c++"); 
        al.Add("c"); 
        al.Add("javascript"); 

        Console.WriteLine(al.LastIndexOf("c"));
        Console.WriteLine(al.LastIndexOf("nodejs"));
    }
}
     
 
      
      
/*
run:
      
6
-1
      
*/

 



answered Apr 22, 2020 by avibootz
...