Represents the method that defines a set of criteria and determines whether the specified object meets those criteria.
- T
- Documentation for this section has not yet been entered.
- obj
- Documentation for this section has not yet been entered.
true if obj meets the criteria defined within the method represented by this delegate; otherwise, false. true if obj meets the criteria defined within the method represented by this delegate; otherwise, false.Documentation for this section has not yet been entered.
This delegate is used by several methods of the Array and List`1 classes to search for elements in the collection.
Typically, the Predicate`1 delegate is represented by a lambda expression. Because locally scoped variables are available to the lambda expression, it is easy to test for a condition that is not precisely known at compile time. This is simulated in the following example, which defines a HockeyTeam class that contains information about a National Hockey League team and the year in which it was founded. The example defines an array of integer values that represent years, and randomly assigns one element of the array to foundedBeforeYear, which is a variable that is locally scoped to the example's Main method. Because locally scoped variables are available to a lambda expression, the lambda expression passed to the List`1.FindAll(Predicate<`0>) method is able to return a HockeyTeam object for each team founded on or before that year.
code reference: System.Predicate`1#3