本文整理汇总了C#中Function.Call方法的典型用法代码示例。如果您正苦于以下问题:C# Function.Call方法的具体用法?C# Function.Call怎么用?C# Function.Call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Function
的用法示例。
在下文中一共展示了Function.Call方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Function add = new Function(new Binary<double, double, NumberValue>(Add));
Function repeat = new Function(new Binary<NumberValue, string, TextValue>(Repeat));
Value v0 = add.Call(new Value[]{ new NumberValue(1), new NumberValue(1) });
Debug.Assert(v0 != null && v0 is NumberValue);
System.Console.WriteLine("add(1, 1) = " + (v0 as NumberValue).value);
Value v1 = add.Call(new Value[]{ new NumberValue(1), new TextValue("foo") });
Debug.Assert(v1 is ErrorValue);
Value v3 = repeat.Call(new Value[]{});
Debug.Assert(v3 is ErrorValue);
Value v4 = repeat.Call(new Value[]{ new NumberValue(14), new TextValue("ab") });
Debug.Assert(v4 is TextValue);
System.Console.WriteLine("repeat(14, \"ab\") = " + (v4 as TextValue).value);
}
示例2: EvaluateCallObject
public void EvaluateCallObject()
{
Machine machine = new Machine();
ICommand body = new ReturnCommand(new ArithmeticBinaryExpression(ArithmeticOperator.Add, new VariableExpression("x"), new DotExpression(new VariableExpression("this"), "Age")));
Function function = new Function(new string[] { "x" }, body);
DynamicObject person = new DynamicObject();
person.SetValue("Age", 30);
Assert.AreEqual(40, function.Call(person, new object[] { 10 }));
}