Stav Alfi
Stav Alfi

Reputation: 13953

Expression.Invoke - What does it do?

http://msdn.microsoft.com/en-us/library/bb355170.aspx

I could not understand what that class is for if it does not have the ruslt of the delegate I want to invoke..

Upvotes: 1

Views: 500

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1503270

Expression.Invoke doesn't immediately invoke the given expression - it creates an expression tree representing the invocation of the given expression. That's what expression trees are all about.

If you want to actually execute an expression tree, you need to build a LambdaExpression, call Compile on it (which will build a delegate) and then invoke the delegate.

Upvotes: 9

Related Questions