eval(string) to C# code
c#, evaluation, runtime
Solution
I'm not entirely sure what you are saying. Can you try clarifying it a bit?
Are you wanting to to take a string expression and evaluate it at runtime in C#? If so the answer is no. C# does not support such types of dynamic evaluation.
Problem
Is it possible to evaluate the following in C# at runtime I have a class that contains 3 properties (`Field`,`Operator`,`Value`) ``` rule.Field; rule.Operator; rule.Value; ``` this is my rule class... Now I have a loop ``` foreach(item in items) { // here I want to create a dynamic expression to evaluate at runtime // something like if (item.[rule.field] [rule.operator] [rule.value]) { do work } } ``` I just don't know the syntax, or if its possible in C#, I know in JS its possible but that's not a compiled language. Update Essentially I want a way to `eval(stringCode)` or a better more supported way.