I need a function to evaluate the value of a string as C# code. The string contains local variables and arithmetic operations, and the function works as if the string is the code in the same place. Something like:
int a = ...; int b = ...; int c = ...;
...
int result = Eval("a+b+c"); // should return current value a+b+c
We can limit the discussion to the simple types like int and arithmetic operations between them. Is it possible to do that in C#/.Net? It is acceptable to pass in context parameter to the function, say, containing the name and value of all required variables.
Thanks!