Can you explain to me:
- What is a Predicate Delegate?
- Where should we use predicates?
- Any best practices when using predicates?
Descriptive source code will be appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A predicate is a function that returns
trueorfalse. A predicate delegate is a reference to a predicate.So basically a predicate delegate is a reference to a function that returns
trueorfalse. Predicates are very useful for filtering a list of values – here is an example.Now if you are using C# 3 you can use a lambda to represent the predicate in a cleaner fashion: