"Ph. VALLAR" <Ph******@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Is it possible to execute a C# string inside a méthod ?
I would like duplicate the same behavior than DataBinder.Eval méthod.
Example:
string code = "this.myProperty * 5;";
object result = someCSharpEvaluationObject.Eval(code);
No, atleast not natively. You could write a parser and execution engine, but
that is a significant project. There *may* be a third party solution
available, but I Don't know of one.
There is a mechanism using jscript, but I don't think it will do what you
want. The jscript eval method executes in the context of the method that
calls it, which will likely not allow you to use this, etc as the method
would exist in a jscript assembly instead of in a C# one.