所以,我想做类似的事情:
Class A
{
public static A operator + (A left, A right)
{
//Calculations
return new A();
}
}
Class B : A
{
public static B operator + (B left, B right)
{
//Calculations
base.+(left,right);
return new A();
}
}
编辑
编辑:
如果不对基类进行类型转换就可以实现这一点,因为它变得丑陋:
public static Sums operator -(Sums operand1, Sums operand2)
{
Sums res = new Sums(operand1._parent);
res = (Sums) (operand1 - (srp_AccountPension.PensionSums)operand2);
return res;
}
我不喜欢来回转换到基类并再次转换到派生类......