A simple demonstration of parsing an expression and then evaluating it.

ID: 396

See: Parse
				
					using uCalcSoftware;

var uc = new uCalc();
Console.WriteLine("Parsing the expression '100 / 4'...");
using (var parsedExpr = new uCalc.Expression("100 / 4")) {
   //var parsedExpr = uc.Parse("100 / 4");

   Console.WriteLine("Evaluating the result...");
   Console.WriteLine($"Result: {parsedExpr.Evaluate()}");
}
				
			
Parsing the expression '100 / 4'...
Evaluating the result...
Result: 25
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   cout << "Parsing the expression '100 / 4'..." << endl;
   {
      uCalc::Expression parsedExpr("100 / 4");
      parsedExpr.Owned(); // Causes parsedExpr to be released when it goes out of scope
      //var parsedExpr = uc.Parse("100 / 4");

      cout << "Evaluating the result..." << endl;
      cout << "Result: " << parsedExpr.Evaluate() << endl;
   }
}
				
			
Parsing the expression '100 / 4'...
Evaluating the result...
Result: 25
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Console.WriteLine("Parsing the expression '100 / 4'...")
      Using parsedExpr As New uCalc.Expression("100 / 4")
         '//var parsedExpr = uc.Parse("100 / 4");
         
         Console.WriteLine("Evaluating the result...")
         Console.WriteLine($"Result: {parsedExpr.Evaluate()}")
      End Using
   End Sub
End Module
				
			
Parsing the expression '100 / 4'...
Evaluating the result...
Result: 25