C# Eval Expression - Execute Complex

CSharp · Console

/Program.cs

using System;
using Z.Expressions;

string formula = @"
            (BasePrice * Math.Pow(1 + InterestRate, Years)) 
            + (ExtraFees * (1 + TaxRate))
        ";

var parameters = new
{
    BasePrice = 10000.0,
    InterestRate = 0.05,
    Years = 3,
    ExtraFees = 250,
    TaxRate = 0.16
};

double totalAmount = Eval.Execute<double>(formula, parameters);

Console.WriteLine($"Total Calculated Amount: {totalAmount:F2}");
;