Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first matching element in the entire list<T> .
namespaces: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Grammar
public int findindex (predicate<t> match)
Parameters
- Match
-
Type: system.predicate<t>
predicate<T> delegate that defines the condition of the element to search for.
return value type:System.Int32
The zero-based index of the element if the first element that matches the criteria defined by the match is found; otherwise-1.
The t is actually the _itemlist passed over the parameters, this function is actually again do the traversal, but the predicate of judgment, directly with an anonymous function instead of;
int index = _itemlist.findindex (t=>t==sender. Getcomponent<basepartneritem> ());
Can also be written like this
int index = _itemlist.findindex (Isbasepartneritem);
private bool Isbasepartneritem (Basepartneritem BPI)
{
if (BPI = = ==sender. Getcomponent<basepartneritem> ())
return true;
Else
return false;
}
List<t>. FindIndex Method (predicate<t>)