Junior — Middle
Can you explain what is meant by the concept of Predicate in programming?
sobes.tech AI
Answer from AI
In programming, particularly in C#, a Predicate is a delegate that represents a method accepting one parameter and returning a boolean value. It is used to define a condition or criterion that an object must satisfy.
Example of using Predicate:
Predicate<int> isEven = x => x % 2 == 0;
bool result = isEven(4); // true
Here, isEven is a Predicate that checks whether a number is even.