How to cast Expression> to Expression>

后端 未结 4 1835
借酒劲吻你
借酒劲吻你 2020-11-29 02:12

I\'ve been searching but I can\'t find how to cast from the type

Expression>

to the type:

Exp         


        
4条回答
  •  无人及你
    2020-11-29 02:51

    Just define the out TResult as object and compile the expression, it works for all data types;

    Expression> dateExp = text => DateTime.Now;
    object dt = dateExp.Compile()("hi");
    Console.WriteLine(dt);
    

    Fiddle sample here

提交回复
热议问题