Is there a way to calculate the result of a string expression, for example
mystring = "2*a+32-Math.Sin(6)"
dynamically knowing that a is a variable that I have, may be there is some dynamic solution or using System.Reflection
string mystring = "2*a+32-Math.Sin(6)"`;
decimal result = SomeMethod(mystring,3); // where a = 3 for example
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…