I have a C# string which is representation of a mathematical expression, something like this:
A = (B*0.25)+(D*0.25)+(1-W)
how can I calculate value of A? should I manually parse all characters, then perform my calculation? Although it is possible but I think it would be time-consuming to write such a code, is there any way that C# can understand this string and calculate value of A (of course I would declare A, B, D & W as variables
thanks
There isn’t such a thing in .net itself, but if you have just primary operations you can parse input string and find related values, for this you can use shunting yard algorithm or reverse polish notation, but also you can use NCalc for more complicated scenarios.