IList<T>.FindIndex(Int32, Predicate <T>)

.net-3.5, c#

Solution

Well you can really easily write your own extension method:

public static int FindIndex<T>(this IList<T> source, int startIndex,
                               Predicate<T> match)
{
    // TODO: Validation
    for (int i = startIndex; i < source.Count; i++)
    {
        if (match(source[i]))
        {
            return i;
        }
    }
    return -1;
}

Problem

There is a `List<T>.FindIndex(Int32, Predicate <T>)`. That method is exactly what I want to for a `IList<T>` object. I know `IList` has a method `IndexOf(T)` but I need the predicate to define the comparing algorithm. Is there a method, extension method, LINQ or some code to find the index of an item in a `IList<T>`?

Original source