Func is a delegate (pointer) to a method, that takes zero, one or more input parameters, and returns a value.
Example for Action and Func:
class Program { static void Main(string[] args) { Action<int,int> testAction = new Action<int,int>(Add); testAction.Invoke(123,234); Func<int,int, double> testFunc = new Func<int,int, double>(Multiply); Console.WriteLine(testFunc(5,6));
} static void Add(int i,int j) { Console.WriteLine(i+j); } static double
Multiply
(int i,int j) { return (double)i*j; } }
No comments:
Post a Comment