Compiling statement collection to an action

c# dynamic expression-trees

Question

So lets say I want to return an action like so ...

public Action<T1, T2> BuildActionFrom(object[] stuff)
{
     BinaryExpression[] expressions = BuildExpressions(stuff);
     return (x,y) => {
          foreach(var ex in expressions) ex(x,y);
     };
}

... how might I go about building this as I can't find anyhting in the expression building api that seems to allow me to build that return value?

Each of my expressions are pretty simple (basic property assignments and what not), I just can't figure out how to put them together.

1
0
7/31/2018 8:02:43 PM

Accepted Answer

Found it ...

Expression.Block(expressions);

... was what i was looking for!

0
7/31/2018 8:50:01 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow