c# - Getting the result from an Expression -
I have created a lambda expression on runtime, and to evaluate it - how can I do this? I just want to express not against any collection or other values.
At this level, once it has been created, I can see that this type of expression & lt; Func & lt; Bool & gt; & Gt;
, with the value of {() = & gt; "MyValue" .StartsWith ("MyV")}
.
I thought that at that point I just got the var result = expression. Invoke (expr, null); / Code> Against this, and I will have my Boolean results but it only gives a
invitation expression
, which looks like (= =) => MyValue. StartsWith ("MyV"))}
.
I'm pretty sure I am close, but do not know how to get my results!
Thank you.
Try compiling the expression with the method, then apply the returned rep:
using the system; Using System.Linq.Expressions; Class example {static zero} (expression & lt; funk & lt; boolean & gt; & gt; expression = () = & gt; "myValue" .StartsWith ("MyV"); & lt; boolean & Gtc: Func = expression.Compile (); Boolean results = throw ();}}
Comments
Post a Comment