1.委托(delegate):
定义一个变量,存储函数。
delegate double MyDelegate(double num1, double num2);
static double Multipy(double n1,double n2)
{
return n1 * n2;
}
static double Divide(double n1, double n2)
{
return n1/n2;
}
static void Main(string[] args)
{
MyDelegate de;
de = Multipy;
Console.WriteLine(de(2, 4.3));
de = Divide;
Console.WriteLine(de(10, 5));
Console.ReadKey();
}