What is the difference between Func, Action and Predicate?
Short answer
Func returns a value; Action returns void; Predicate is a Func used for tests.
Advertisement
AModel answer
Func<...,TResult> returns a value; Action<...> returns void; Predicate<T> is a Func<T,bool> used for tests.
Func<int,bool> isEven = n => n%2==0;
Action greet = () => Console.Write("hi");Real-world example
Passing isEven to List.FindAll to filter numbers.