在vb2010而不是c#中创建自定义函数的等效代码是什么?
Expression e = new Expression("SecretOperation(3, 6)");
e.EvaluateFunction += delegate(string name, FunctionArgs args)
{
if (name == "SecretOperation")
args.Result = (int)args.Parameters[0].Evaluate() + (int)args.Parameters[1].Evaluate();
};
答案 0 :(得分:4)
这是怎么做的!
Imports NCalc
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim exp As New Expression("SecretOperation(3, 6)")
AddHandler exp.EvaluateFunction, Sub(str, args)
If str = "SecretOperation" Then
args.Result = CInt(args.Parameters(0).Evaluate() + args.Parameters(1).Evaluate())
End If
End Sub
End Sub
End Class