Does anyone know of a more up-to-date expression evaluator than NCalc? The last release was in 2011 and a (very) quick Google search returned pretty much nothing from what I could see.
-
You can try to [find a fork that someone else maintains](https://github.com/search?utf8=%E2%9C%93&q=ncalc&type=) or roll it yourself. I've had good luck forking [NCalc-Edge](https://github.com/pitermarx/NCalc-Edge) (which also happens to live in NuGet). – drzaus Aug 24 '17 at 15:03
5 Answers
I know this is a late response but for the good of others searching and maybe yourself. Have you looked at Roslyn ? I believe that Microsoft are using it themselves now. You can pass simple c# or vb.net expressions for evaluation of complete code. Example below shows a simple math problem.
ScriptEngine roslynEngine = new ScriptEngine();
Roslyn.Scripting.Session session = roslynEngine.CreateSession();
session.AddReference("System.Web");
session.ImportNamespace("System");
session.ImportNamespace("System.Web");
var result = (session.Execute("1 + 1"));

- 1,823
- 1
- 13
- 14
-
1Good answer in that it pointed me in the right direction. Better would include what dll/nuget package Roslyn.Scripting.Session lives in. – Rig Jul 29 '15 at 11:47
-
Update see Scripting API Samples https://github.com/dotnet/roslyn/wiki/Scripting-API-Samples for samples of Roslyn Scripting which is available in .NET Framework 4.6+, or .NET Core 1.1 (supported since Roslyn v2.0.0-rc3, Visual Studio 2017 RC3). – Steve Apr 20 '19 at 22:53
-
During testing with real example/task i have encountered following issues: - there is performance issue - expression must be precompiled, cached - next time it is more better but .. - there is issue with dll - result of compilation is dll, which loading in memory, without good way to wokr with it – Anatoliy Kostyuk Mar 27 '23 at 11:01
There is a fork on github here which is more up-to-date.
At the moment I don't know if the quality is better.

- 3,501
- 2
- 29
- 34
-
1This one worked for me for building a Unity app to Android and iOS, whereas the original NCalc would throw an Exception on Android. – CasualCoder May 03 '18 at 22:53
I fully appreciate how late this answer is however I would like to throw in my solution because I believe it can add more above the accepted answer of using NCalc should someone wish to use the expressions across multiple platforms.
-- Update --
I have created a parser for C# with plans to also implement it for Java and Swift over the next few months. This would mean that you can evaluate the expressions on multi-platforms without the need for tweaking per platform.
While Java and Swift was planned it never made it in to a fully fledge release. Instead there is now support for .NET Standard
enabling support for Xamarin
apps.
-- End update --
Expressive is the tool and it is available at: GitHub or Nuget.
The site has a fair amount of documentation on it but to prevent link rot here is an example on how to use it:
Variable support
var expression = new Expression("1 * [variable]");
var result = expression.Evaluate(new Dictionary<string, object> { ["variable"] = 2);
Functions
var expression = new Expression("sum(1,2,3,4)");
var result = expression.Evaluate();
It was designed to match NCalc as best as possible however it has added support for things like a 'null' keyword.
This answer is a duplicate of Expressive answer. I have duplicated it in case of link rot.

- 3,661
- 5
- 35
- 52
-
1What is particularly interesting is the ability to retrieve variable immediately after compilation without to have to hook a event. I will definitely give this a try. – Larry Sep 26 '18 at 06:39
-
@Larry thanks, I hope it works well for you. We found we needed the ability to retrieve the variable names as we compiled expressions at runtime and then needed to know which dynamic values to supply in as variables. – Bijington Sep 26 '18 at 08:27
-
Sadly, Expressive lacks support of ternary operators. Also the ability to evaluate referenced parameters after compiling is not an additional feature but **replaces** the hooks, which means you are bound to create a parameter dicitonary yourself. For me, the lack of support for "[var] ? 'Yes' : 'No'" kills it – Wortex17 Jul 11 '19 at 08:57
-
@Wortex17 I had briefly investigated ternary operator support but never went through with it as I didn’t have a use case for it. I’ll happily raise a feature request to add it in though :) – Bijington Jul 11 '19 at 10:41
Late to the party, but here's one being regularly updated, also read it outperforms NCalc:
https://www.nuget.org/packages/Jace/
Hope it helps.

- 948
- 1
- 17
- 27
I know this is an extremely late response (7 years late)
There is a fork which is still developed, available here: https://github.com/ncalc/ncalc

- 77
- 8