自定义:
class MathOperations
{
public static double Multiplybytwo(double value) { return value*2; } public static double Square(double value) { return value * value; }
}
delegate void test(double test1)
class Program
{
static void Main()
{
test[] operations={MathOperations.Multiplaybytwo,MathOperations.Square};
for(int i=0;i<operations.Length;i++)
{
ProcessAnddiaplayNumber(operations[i],99);
}
}
static void ProcessAnddisplaynumber(test action,double value)
{double result=action(value);}
}
//Action<T>无返回 类型,Fun<>T,需要返回类型
Func<double ,doubel> operation={Mathoperations.Multioplauybytewo,Mathoperations.square};
static void ProcessAnddisplaynumber(Func<double ,doubel> action,double value)
{double result=action(value);}
}