When to use Func, Action And Predicate Delegates

Ronald Rex 1,666 Reputation points
2022-08-29T16:42:32.26+00:00

Hi Friends. I just wanted to ask a question in regards to what areas or components in software architecture or development are best suited for using Func, Action And Predicate Delegates. Thanks for any articles or references to blogs.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,366 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,230 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Jack J Jun 24,286 Reputation points Microsoft Vendor
    2022-08-30T01:44:50.567+00:00

    @Ronald Rex , Welcome to Microsoft Q&A,

    If you want to return one result with zero, one or more input parameters, you could use Func Delegate.

    If you don't want to return result with zero, one or more input parameters, you could use Action Delegate.

    If you want to return a bool type result with zero, one or more input parameters, you could use Predicate Delegate.

    You could refer to the following links to know more about it.

    Func vs. Action vs. Predicate

    Delegates: Predicate vs. Action vs. Func

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments