How to find index of an element in the list using lambda expressions in C#

1 Answer

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

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main()
        {
            List<int> list = new List<int>() { 2, 6, 13, 19, 32, 53, 99 };

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

            Console.WriteLine(i);
        }
    }
}


/*
run:
   
2
 
*/

 



answered Aug 25, 2018 by avibootz

Related questions

1 answer 259 views
259 views asked Jan 18, 2022 by avibootz
1 answer 288 views
1 answer 167 views
1 answer 149 views
1 answer 88 views
1 answer 136 views
...