Writing is my profession! I have written hundreds of article for many organizations and looking forward to work with growing organization. I am compatible to produce content in many categories including International politics, Healthcare, Education, Lifestyle, etc.. I understand the value of your time that you have invested to read my bio. #thanks
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
Liked By
Write Answer
Can elaborate difference between Func vs. Action vs. Predicate?
Join MindStick Community
You have need login or register for voting of answers or question.
Aryan Kumar
30-May-2023Sure. 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: