How to find the index of the first odd element in a List with C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>() { 10, 20, 25, 30 };

            int index = list.FindIndex(i => i % 2 != 0);

            Console.WriteLine(index);
        }
    }
}


/*
run:
  
2
 
*/

 



answered Jan 9, 2017 by avibootz
...