Maha

Maha

  • NA
  • 600
  • 70.5k

FindIndex() method

Jan 11 2016 10:24 AM

1st program is a List program, uses the FindIndex() method and it is executing well.

2nd program is an Array program also uses FindIndex() method and it is  not executing. How to make it executing.

 1st program

 using System;

using System.Collections.Generic;

class Program

{

    static void Main()

    {

        List<int> elements = new List<int>() { 10, 20, 31, 40 };

         int oddIndex = elements.FindIndex(x => x % 2 != 0);

        Console.WriteLine(oddIndex);//2

         Console.ReadKey();

    }

}

 2nd program

 using System;

 class Program

{

    static void Main()

    {

        int[] array = { 15, 6, 7, 16 };

         int index = array.FindIndex(x => x == 6);

         Console.WriteLine("{0}", index);

         Console.ReadKey();

    }

}


Answers (1)