In C #: expression evaluation function like flash script

Duplicate: How can I evaluate a C # expression dynamically?

See Also: C # Equivalent Equivalent?

How to evaluate the expression. Maybe like:

int a=1; int b=3; int c=Eval("a+b"); 

or

 int c=int.parse("1+3*(2+3)"); 

That seems silly to me. is this possible in c #?

+4
source share
2 answers

You can take the code, and using CSharpCodeProvider, write an Eval function that actually compiles your code into an assembly in memory and then executes that code.

See the CodeProject article for an example source.

+6
source

Not directly. C # does not contain a runtime compiler. There is an open source project attached to Mono that will do this.

+2
source

All Articles