Answers for "how to find all indexes of an element in a list c#"

C#
3

Get Index position of an element in a list in c#

int index = myList.FindIndex(a => a.Prop == oProp);
Posted by: Guest on April-25-2021
0

c# find all indexes

public static int[] FindAllIndexOf<T>(this T[] array, Predicate<T> filter)
        {
  			// Note: If select does not find a match returns index as "-1"
            int[] indexes = array.Select((elementInArray, index) => filter(elementInArray) ? index : -1)
                                 .Where(index => index != -1).ToArray();

            return indexes;
        }
Posted by: Guest on June-17-2021

Code answers related to "how to find all indexes of an element in a list c#"

C# Answers by Framework

Browse Popular Code Answers by Language