[Serializable]
public class DevisionFunctionInfo : FunctionInfo
{
public override string Name { get { return "Devision"; } }
public override int MinArgs { get { return 2; } }
public override int MaxArgs { get { return 2; } }
public override object Evaluate(object[] args)
{
object num1 = args[0]; //除数
object num2 = args[1]; //被除数
if (Convert.ToInt32(num2) == 0 || string.IsNullOrEmpty(Convert.ToString(num1)) || string.IsNullOrEmpty(Convert.ToString(num2)))
return ""; //return null
return Convert.ToSingle(num1) / Convert.ToSingle(num2);
}
}
[Serializable]
public class Devision2FunctionInfo : FunctionInfo
{
public override string Name { get { return "Devision"; } }
public override int MinArgs { get { return 3; } }
public override int MaxArgs { get { return 3; } }
public override object Evaluate(object[] args)
{
object num1 = args[0]; //除数
object num2 = args[1]; //被除数
object num3 = args[2];//修约
if (Convert.ToInt32(num2) == 0 || string.IsNullOrEmpty(Convert.ToString(num1)) || string.IsNullOrEmpty(Convert.ToString(num2)))
return ""; //return null
return CommonFunction.FloatToStringRound((Convert.ToSingle(num1) / Convert.ToSingle(num2)).ToString(), Convert.ToSingle(num3));
}
}
这个是重载的,只调用第二个,第一个不调用,这个不能用 CommonFunction.FloatToStringRound可以先注释掉。 |