is there a .NET library that can perform a numerical operation and return a value?
I have an expression like so:
1 + 1/2
this should return the double equivalent of the same.
I wont be passing a string, it will be a numeric value and the return should be a numeric.
I’ve used NCalc for medium-to-complex calculations and it seems that it will fit your needs.
About the OP’s comment on the original question:
will return 0 in c#, because the integer 1 is divided by the integer 2, resulting in an integer result of 0.
If you need to trigger real-number mathematics, at least one of the operands must be defined as a real number. You can do that by specifying it with a decimal point (1.0 instead of 1), or by adding a type specifier after the value (1f or 1d instead of 1).
Take a look at this example: