List<t>. FindIndex Method (predicate<t>)

Source: Internet
Author: User
Tags mscorlib

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>)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.