using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
public delegate int BinaryOp(IntCalc a);
public class IntCalc
{
public int Result, X;
public IntCalc(int result, int x)
{
Result = result;
X = x;
}
}
public class MyMath
{
public int Addition(IntCalc a)
{
a.Result += a.X;
return a.Result;
}
public int Subtraction(IntCalc a)
{
a.Result -= a.X;
return a.Result;
}
}
class Program
{
static void Main(string[] args)
{
MyMath mm = new MyMath();
BinaryOp bo = mm.Addition;
BinaryOp bo1 = mm.Subtraction;
BinaryOp all = bo;
all += bo1;
Console.WriteLine("{0}", all(new IntCalc(14, 40)));
Console.ReadKey();
}
}
}