Navaneeth Krishnan
How to find index in linq query
By Navaneeth Krishnan in .NET on Aug 22 2020
  • Archana Parmar
    Sep, 2020 24

    List ostring = new List();
    ostring.Add(“Archana”);
    ostring.Add(“P”);
    ostring.Add(“Parmar”);
    ostring.Add(“Check”);
    ostring.Add(“index”);

    1. IEnumerable<int> indexes = (from item1 in ostring
    2. where item1== "Check"
    3. select ostring.IndexOf(item1));
    4. Console.WriteLine(indexes.FirstOrDefault());

    //Hope you are looking for this //

    • 0
  • Nisha Regil
    Sep, 2020 11

    LINQ does not have an IndexOf method. So to find out index of a specific item we need to use FindIndex as int index = List. FindIndex(your condition);

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS