Introduction
We learned what delegates are in this article.
Whenever we use delegates, we have to declare a delegate, initialize it, and then call a method with a reference variable.
In order to get rid of all the first steps, we can directly use Func, Action, or Predicate delegates.
- The Func delegate takes zero, one or more input parameters, and returns a value (with its out parameter).
- The action takes zero, one or more input parameters, but does not return anything.
- Predicate is a special kind of Func. It represents a method that contains a set of criteria mostly defined inside an if condition and checks whether the passed parameter meets those criteria or not.
It takes one input parameter and returns a boolean - true or false.
Note. You can use all three of them with anonymous methods and lambda expressions.
Let's first learn the Func delegate.
Syntax 1
One input parameter and one return parameter.
public delegate TResult Func<int T, out TResult>(T arg);
Syntax 2
Two input parameters and one return parameter.
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg, T2 arg2)
The last parameter in the angle brackets <> is considered as the return type, and the remaining parameters are considered as input parameter types. It can have 0 - 16 input parameters.
Func with 0 parameters
Func<int> SomeMethodName;
It still has one parameter; it is a return type because func always returns something.
class Program
{
static void Main(string[] args) public delegate TResult Func<in T1, in T2, out TResult>(T1 arg, T2 arg2)
{
Func<int,int,int> Addition = AddNumbers;
int result = Addition(10, 20);
Console.WriteLine($"Addition = {result}");
}
private static int AddNumbers(int param1, int param2 )
{
return param1 + param2;
}
}
Func with an Anonymous Method
Func<int,int,int> Addition = delegate (int param1, int param2)
{
return param1 + param2;
};
int result = Addition(10, 20);
Console.WriteLine($"Addition = {result}"); 
Amr AbazaPosted Jun 11, 2026, 8:05 PM
Good topic, I think you shall update the 1st example in predicates(IsApple), you successfully instantiate a predicate but never use it as you call method directly. This can be misleading for beginners.
Povilas SimanskasPosted Jan 18, 2022, 7:12 AM
Line 6: bool result = IsApple("I Phone X"); << method is called directly, not the predicate. Or have I mistaken?