📅  最后修改于: 2022-03-11 14:49:20.790000             🧑  作者: Mango
// Declare a delegate type
public delegate double MyDelegateType(double x);
// Define some consummer that uses functions of the delegate type
public double Consummer(double x, MyDelegateType f){
return f(x);
}
//...
// Define a function meant to be passed to the consummer
// The only requirement is that it matches the signature of the delegate
public double MyFunctionMethod(double x){
// Can add more complicated logic here
return x;
}
// In practice now
public void Client(){
double result = Consummer(1.234, x => x * 456.1234);
double secondResult = Consummer(2.345, MyFunctionMethod);
}