static void Main(string[] args) { Console.WriteLine("Delegate Test"); MyMath Plus = new MyMath(plus); MyMath Minus = new MyMath(minus); MyMath Multiply = new MyMath(multiply); Calculator(11, 22, plus); Calculator(33, 22, minus); Calculator(11, 22, multiply); Console.WriteLine("Delegate Test - general <T>"); MyMathT <int> Plus_int = new MyMathT <int> (plus); MyMathT <float> Minus_float = new MyMathT <float> (minus); MyMathT <double> Multiply_double = new MyMathT <double>(multiply); Calculator(11, 22, plus); Calculator(3.3f, 2.2f, minus); Calculator(11.3, 22.7, multiply); Console.WriteLine("Delegate Test - chain"); MyDelegate myDelegate = new MyDelegate(func1); myDelegate += func2; myDelegate += func3; }
static void CalculatorT <T>(T a, T b, MyMathT <T> myMath) { Console.WriteLine(myMath(a, b)); }