public int Evaluate() { if (!IsConstant()) { throw new InvalidOperationException(); } switch (Op) { case ArithSpec.Add: return(S1.Evaluate() + S2.Evaluate()); case ArithSpec.Subtract: return(S1.Evaluate() - S2.Evaluate()); case ArithSpec.Multiply: return(S1.Evaluate() * S2.Evaluate()); case ArithSpec.Divide: return(S1.Evaluate() / S2.Evaluate()); default: throw new InvalidOperationException(); } }