先來看看下麵一個類中的一些方法: class Bc { public double Add(double number1, double number2) { return number1 + number2; } public double Multiply(double number1, dou ...
class Bc { public double Add(double number1, double number2) { return number1 + number2; } public double Multiply(double number1, double number2) { return number1 * number2; } public double Subtract(double number1, double number2) { return number1 - number2; } public double Division(double number1, double number2) { return number1 / number2; } }Source Code
class Bd { public delegate double CalcResult(double number1, double number2); public void TestDelegate() { Bc objBc = new Bc(); CalcResult obj = new CalcResult(objBc.Multiply); Console.WriteLine(obj(2, 5)); } }Source Code
在控制台運行: