Sure. Func, Action, and Predicate are all delegates in C#. A delegate is a reference to a method. Func, Action, and Predicate differ in the type of method they refer to.
Func refers to a method that takes zero or more parameters and returns a value.
Action refers to a method that takes zero or more parameters and does not return a value.
Predicate refers to a method that takes one parameter and returns a boolean value.
Here are some examples of how Func, Action, and Predicate can be used:
Func can be used to create a function that takes two numbers as input and returns their sum.
Action can be used to create a function that prints the current date and time.
Predicate can be used to create a function that checks if a number is even.
Here is a table that summarizes the differences between Func, Action, and Predicate:
Delegate
Parameters
Return type
Func
Zero or more
Value
Action
Zero or more
Void
Predicate
One
Boolean
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Sure. Func, Action, and Predicate are all delegates in C#. A delegate is a reference to a method. Func, Action, and Predicate differ in the type of method they refer to.
Here are some examples of how Func, Action, and Predicate can be used:
Here is a table that summarizes the differences between Func, Action, and Predicate: