dynamicexpresso / DynamicExpresso

C# expressions interpreter
http://dynamic-expresso.azurewebsites.net/
MIT License
2.01k stars 377 forks source link

Hello, I encountered a situation and I would like to know if there is a way to achieve it. Please take a look at my code #320

Open jiangzhuangxiansheng opened 1 month ago

jiangzhuangxiansheng commented 1 month ago

Hello, I encountered a situation and I would like to know if there is a way to achieve it. Please take a look at my code:

var target = new Interpreter() .SetVariable("a", 10) .SetVariable("b", 5); var expression = "a + b";

I would like to obtain the expression "10 + 5"

davideicardi commented 4 weeks ago

Sorry @jiangzhuangxiansheng , but I'm not sure to understand what is your problem. I think you can write something like:

var result = target.Eval("a + b");
jiangzhuangxiansheng commented 3 weeks ago

var expression = target.xxx("a + b") return expression The result is "10 + 5" instead of 15

davideicardi commented 3 weeks ago

Can you show me the full code? I suppose the problem is that the variables that you are using are of type string , not numbers (int, ...).