What is a Predicate Delegate and where should it be used?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
A Predicate<T> in C# is a delegate that takes one value of type T and returns bool. In plain terms, it represents a reusable yes-or-no test, which makes it a natural fit for searching, filtering, validation, and rule-based decisions.
What Predicate<T> Represents
The signature of Predicate<T> is simple: one input, one boolean answer. That shape matches questions such as "is this product sellable" or "should this record be removed."
The point is not just syntax. Moving the rule into a named predicate makes the code easier to read, test, and reuse.
Where Predicate<T> Fits Best
The most obvious home for Predicate<T> is APIs that are already designed for it. List<T> exposes several such methods, including Find, FindAll, Exists, and RemoveAll.
This reads well because the delegate matches the intent of the API: answer a boolean question about each element.
Predicates also work well in validation layers. A named predicate can express business rules more clearly than repeating the same long lambda in several methods.
Predicate<T> Versus Func<T, bool>
You can express the same logical rule with Func<T, bool>. In fact, LINQ methods such as Where expect Func<T, bool>, not Predicate<T>. The difference is mostly about API shape and readability, not meaning.
A practical guideline is simple:
- use
Predicate<T>when working with APIs that explicitly ask for it, especiallyList<T>methods - use
Func<T, bool>when working with LINQ and more general functional pipelines
The logic is the same. The delegate type just follows the method signature that the framework exposes.
Keep Predicates Focused and Side-Effect Free
A predicate should answer a question, not perform work with side effects. If the lambda starts updating counters, writing logs, or mutating external state, the code becomes harder to reason about.
As rules become more complex, compose small predicates instead of writing one huge inline condition.
This style keeps each rule single-purpose and makes tests easier to write.
Common Pitfalls
Writing very long inline predicates makes calling code hard to read. Extract a named predicate when the rule grows beyond a simple condition.
Mixing side effects into a predicate breaks the mental model of a pure yes-or-no test.
Using Predicate<T> where an API expects Func<T, bool> can cause confusion. Match the delegate type to the API you are calling.
Summary
- '
Predicate<T>is a delegate for reusable boolean tests.' - It is especially useful with
List<T>methods such asFind,FindAll,Exists, andRemoveAll. - It improves readability by naming search and validation rules.
- Keep predicates focused, reusable, and free of side effects.
Related reading
- What is a predicate in c?
- What is a proper implementation of the IAsyncResult interface?
- What is a quick way to force CRLF in C / .NET?
- What is a replacement method for Task.Run in .NET 4.0 using C?
- What is a singleton in C?
- What is a .snk for?
- What is a 'workspace' in Visual Studio Code?
- What is an IndexOutOfRangeException / ArgumentOutOfRangeException and how do I fix it?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.