c# delegate action vs func code example
Example: c# func vs action
//A Action is a container to set a method for invoking that has no returns
//where as a Func is a container to set a method for invoking that has returns
//so
//Any Generals or Templates in a Action will always be signiture input params
//Where as to say a function will alway have a output return indicated by the
//last General or Template type and any others will be inputs params.
//Addtionally async invokers (.BeginInvoke) with actions can be fire and forget
//where as a Funcs must be awaited for the result using the EndInvoke
//example using lambda's (Short handed anonymous methods):
//Actions
Action BasicAction = ()=>{/*does something*/};
Action</*in*/ Type> SingleParamiterizedAction = (x)=>{/*does something*/};
Action</*in*/ Type1, /*in*/ Type2> DoubleParamiterizedAction = (x, y)=>{/*does something*/};
//....
Func</*out*/ TResult> BasicFunc = ()=>{/*does something*/ return TheTResult; };
Func</*in*/ Type,/*out*/ TypeResult> SingleParamiterizedFunc = (x)=>{/*does something*/ return TheTypeResult; };
Func</*in*/ Type1, /*in*/ Type2, /*out*/ TypeResult> DoubleParamiterizedFunc = (x, y)=>{/*does something*/ return TheTypeResult; }
//Usage example
BasicAction.Invoke(); //result of void can not be used
TResult TheResult = BasicFunc(); // result of the methods output can be used.