委托
private delegate Decimal OperateDelegate(Decimal operand1,Decimal operand2);
private Decimal Add(Decimal operand1,Decimal operand2)
{
return operand1 + operand2;
}
private Decimal Subtract(Decimal operand1,Decimal operand2)
{
return operand1 - operand2;
}
private Decimal Multiply(Decimal operand1,Decimal operand2)
{
return operand1 * operand2;
}
private Decimal Divide(Decimal operand1,Decimal operand2)
{
if(operand2 == 0)
{

OnDevideByZero += new DevideByZeroEventHandler(frmDelegateDemo_OnDevideByZero);
if(OnDevideByZero != null)
{
DevideByZeroEventArgs args = new DevideByZeroEventArgs();
OnDevideByZero(this,args);
}
return 0;
}
return operand1 / operand2;
}