Surprising generic delegation Predicate/Func/Action

Source: Internet
Author: User

Predicate generic delegation

Defines a set of conditions and determines whether the specified object meets these conditions. This delegatedArrayAndListUsed to search for elements in a collection.

Let's take a look at its definition below:

// Summary:
// Represents the method that defines a set of criteria and determines whether
// The specified object meets those criteria.
//
// Parameters:
// Obj:
// The object to compare against the criteria defined within the method represented
// By this delegate.
//
// Type parameters:
// T:
// The type of the object to compare.
//
// Returns:
// True if obj meets the criteria defined within the method represented by this
// Delegate; otherwise, false.
Public delegate bool Predicate <T> (T obj );

Type parameters:

T:Type of the object to be compared.

Obj:Objects to be compared according to the conditions defined in the methods represented by this delegate.

Return Value: IfObjIf the conditions defined in the methods represented by this delegate are metTrueOtherwiseFalse.

See the following code:

Public class GenericDelegateDemo
{
List <String> listString = new List <String> ()
{
"One", "Two", "Three", "Four", "Fice", "Six", "Seven", "Eight", "Nine", "Ten"
};

String [] arrayString = new String []
{
"One", "Two", "Three"
Related Article

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.