class Program
{
// 声明委托
public delegate Double SquareCallback(Double x, Double y);
public static Double GetSumResult(Double x, Double y)
{
return Math.Pow(x, 2)+Math.Pow(y,2);
}
public static Double GetSubtractionResult(Double x, Double y)
{
return Math.Pow(x, 2) - Math.Pow(y, 2);
}
static void Main(string[] args)
{
SquareCallback sc = GetSumResult; // 给委托对象赋值,委托对象sc指向GetSumResult
Console.WriteLine(sc(2,6));
}
}
温馨提示:答案为网友推荐,仅供参考