call Equal method of Expression

前端 未结 3 899
萌比男神i
萌比男神i 2021-01-28 01:24

when I run this code

Expression left = Expression.Constant(10, typeof(int));
Expression right = Expression.Constant(10,typeof(int));

var method10 = typeof(Expr         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 02:30

    Try

    var exp = Expression.MakeBinary(ExpressionType.Equal, left, right);
    

    instead of

    var method10 = typeof(Expression).GetMethod("Equal", new[] { typeof(Expression), typeof(Expression) });
    Expression exp = Expression.Call(method10,left,right);
    

提交回复
热议问题