Building Expression Evaluator with Expression Trees in C# – Table of Contents

This is table of contents for Building Expression Evaluator with Expression Trees in C# series. We are going to build a simple mathematical expression evaluator in C# using expression trees. The library supports simple expressions such as 2.5+5.9, 17.89-2.47+7.16, 5/2/2+1.5*3+4.58, expressions with parentheses (((9-6/2)*2-4)/2-6-1)/(2+24/(2+4)) and expressions with variables:

var a = 6;
var b = 4.32m;
var c = 24.15m;
Assert.That(engine.Evaluate("(((9-a/2)*2-b)/2-a-1)/(2+c/(2+4))", a, b, c),
            Is.EqualTo((((9 - a / 2) * 2 - b) / 2 - a - 1) / (2 + c / (2 + 4))));

At the end of the series full source code will be available at github and the library will be published to NuGet.

Source code is available at github: Math-Expression-Evaluator

Table of Contents

  1. Building Expression Evaluator with Expression Trees in C# – A basic implementation.
  2. Building Expression Evaluator with Expression Trees in C# – Adding support for parentheses.
  3. Building Expression Evaluator with Expression Trees in C# – Adding support for variables.
  4. Building Expression Evaluator with Expression Trees in C# – Improving the Api
Kick It on DotNetKicks.com
Share

, , ,

More in .Net Framework, c#, expression trees
AppDomain.AssemblyResolve Event Tips

AppDomain.AssemblyResolve event can be used to load referenced assemblies at runtime. This can be useful in multiple scenarios: you can...

How to Get Elevated Process Path in .Net

As you know retrieving process path in .Net is quite straightforward. For example if you have process instance someProcess you...