Expression Trees and Invoking a Delegate

前端 未结 4 1189
余生分开走
余生分开走 2020-12-15 06:10

So I have a delegate which points to some function which I don\'t actually know about when I first create the delegate object. The object is set to

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 06:32

    While other answers provide some working ways there's a shorter one:

    Expression.Invoke(Expression.Constant(my_delegate), parameter_for_delegate)

    It works both for delegates referencing static methods and instance methods with no change.

提交回复
热议问题