2
Reply

What are Action and Func keywords?

Murali Poola

Murali Poola

12y
4.1k
0
Reply

    Action and Func are Generic Delegates in C#Action is a generic Delegate that does not accept any Paramter Input not returns a value.Func is a generic Delegate that accepts Input Parameter and has a return type.General form : Func myFuncDel;

    They are generic types that help cut down on delegate type declarations.  Whereas previously, you'd have to declare your own delegate type for, say, this delegate:
        public delegate int MyDelegate(int arg1, double arg2, string arg3);

    public MyDelegate mInstance;
    You can now declare the instance like this:
    public Func mInstance;
    Without having to declare the delegate type.  The Action<> delegate is the exact same thing, except for delegates that return void.