CalcEngine for .NET
In This Topic
    Parse and Compute Expressions
    In This Topic

    The CalcEngine library is represented by the C1CalcEngine class which contains an IEngine object and provides its interaction with controls. Here, the IEngine interface defines properties and methods of expression engine. The C1CalcEngine class mainly performs two tasks, parsing formula containing strings into Expression objects so that they can be evaluated and evaluating Expression objects to return the result.

    To calculate the formula represented by a string, you need to call Evaluate method of the C1CalcEngine class. It parses the string into an expression, evaluates it and returns the result as shown in the following example:

    C#
    Copy Code
    var calcEngine = new C1CalcEngine();
    calcEngine.Expression = “1+1”;
    var result = calcEngine.Evaluate();