JScript

JavaScript and JScript languages provide a convenient Eval method that allows for dynamic evaluation of expressions. This functionality can be duplicated in C# using Microsoft’s JScript CodeDomProvider and Reflection.

Following class automatically compiles an in-memory assembly using JScript CodeDomProvider. The Eval method uses this assembly to dynamically evaluate specified expressions:

Using this class, we can execute statements such as:

Post a Comment

Be the First to Comment!

wpDiscuz