I know c# has Array.FindAll and Array.IndexOf.
Is there a Array.FindAllIndexOf
which returns int[]
?
I've used Nikhil Agrawal's answer to create the following related method, which may be useful.
public static List FindAllIndexOf(List values, List matches)
{
// Initialize list
List index = new List();
// For each value in matches get the index and add to the list with indexes
foreach (var match in matches)
{
// Find matches
index.AddRange(values.Select((b, i) => Equals(b, match) ? i : -1).Where(i => i != -1).ToList());
}
return index;
}
Which takes a list with values and a list with values that are to be matched. It returns a list of integers with the index of the matches.