Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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;
        }
 
PREVIOUS NEXT
Tagged: #find #indexes
ADD COMMENT
Topic
Name
9+1 =