Cor*_*son 5

Expression.Parameter()支持ByRef类型(即ref参数),Expression.Variable()如果给定一个则抛出异常.

它们在其他方面是相同的,但这是一个实现细节,你不应该依赖它:

public static ParameterExpression Parameter(Type type, string name)
{
    bool isByRef = type.IsByRef;
    if (isByRef)
    {
        type = type.GetElementType();
    }
    return ParameterExpression.Make(type, name, isByRef);
}

public static ParameterExpression Variable(Type type, string name)
{
    if (type.IsByRef)
    {
        throw Error.TypeMustNotBeByRef();
    }
    return ParameterExpression.Make(type, name, false);
}
Run Code Online (Sandbox Code Playgroud)