Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

Action, Func, Predicate (and other C# System-Level Delegates)

Tags: C#

C# Delegate Types

C# has several System-level delegate types. Here are the most popular:

  • Action
  • AsyncCallback
  • Comparison
  • Converter
  • EventHandler
  • Func
    • Takes zero to 16 parameters.
    • Returns a value specified by TResult.
    • Func<TResult>
    • Func<T1, TResult>
    • Func<T1, …, T16, TResult>
  • Predicate
    • Has one parameter.
    • Returns a bool.
    • Predicate<T>

We instantiate C# delegate types in three ways:

  • Named Methods
  • Anonymous Methods, and
  • Lambdas

See also:

How to: Declare, Instantiate, and Use a Delegate (C# Programming Guide)

System Delegates