using System;
namespace NilPointer
{
class Program
{
public delegate double CalCulate(double a, double b);
public static double Add(double a, double b)
{
return a + b;
}
public static double Sub(double a, double b)
{
return a - b;
}
public static double Mul(double a, double b)
{
return a * b;
}
static void Main(string[] args)
{
CalCulate calCulate = Add;
calCulate += Sub;
calCulate += Mul;
var result1 = calCulate(10, 2);
Console.WriteLine("result 1: " + result1);
calCulate -= Sub;
calCulate -= Mul;
var result2 = calCulate(10, 2);
Console.WriteLine("result 2: " + result2);
Console.ReadLine();
}
}
}
result 1: 20
result 2: 12