A generic delegate is actually a predefined delegate of the. NET framework that basically covers all the commonly used delegates, so it is generally not necessary for users to declare them again. simple and convenient .
' 1 generic delegate with no return value
The Action series generic delegate is a delegate that has no return parameter, and the call is not declared as a normal delegate.
Example:
Action test1 = () => {Console.WriteLine ("Void Method ();");
Action<int, double> test2 = (int x, double y) => {Console.WriteLine ("Void Method (T1, T2)");
Test1 ();
Test2 (2, 3);
"2" has a generic delegate with a return value
Func Series Generic delegate, is a delegate with a return value, and the last parameter represents a return parameter.
Example:
func<int> test3 = () => {return (a);};
Func<double, int> test4 = (double x) => {return (int) (x * 2);
Console.WriteLine (Test3 ());
Console.WriteLine (Test4 (1.2));