score:3

Accepted answer

Use the Expression.Constant factory method:

class StackInfo
{
    protected Stack<SomeClass> _stack;

    public Expression Push(SomeClass item)
    {
        MethodInfo mi = _stack.GetType().GetMethod("Push");

        return Expression.Call(Expression.Constant(_stack), mi, Expression.Constant(item));
    }
}

Related Articles