im trying to rewrite some VBA code in C#.
The VBA function takes a string like
"4 > 2 AND 10 <> 62" or
"'False' = 'False' AND 6 <> 7" or
"'True' = 'False' AND (4 = 2 OR 4 = 4)".
(Without the "" marks)
VBA has an implemented function called "Application.Eval()".
This function can evaluate these strings and return true or false. Text comparison is no
Problem.
DIM evalResult as Boolean
evalResult = Application.Eval("4 > 2 AND 10 <> 62") 'Would return true
evalResult = Application.Eval("'True' = 'False' AND (4 = 2 OR 4 = 4)") 'Would return false
evalResult = Application.Eval("'True' = 'True' AND (4 = 2 OR 4 = 4)") 'Would return True
Now i tried to to the same in c# and evaluate these strings using NCalc.
But NCalc seems to only handle numerical operations and i did not find any mentioning of a similar function in c#.
Is there a built in function or something similar in C# to the Application.Eval() function in VBA?
Okay, nvm. If i replace "AND" with "&" and "OR" with "|" in the string, it works and returns the right bool.