Patrik Lundin, patrik lundin.info
Download the info.lundin.Math assembly here
This .NET assembly contains a math parser written in C#, it evaluates a mathematical expression
and returns a double value.
Example:
// Import the assembly that contains the parser
using info.lundin.Math;
// some other imports
using System;
using System.Collections;
public class Test
{
public static void Main( String[] args )
{
// Instantiate the parser
ExpressionParser parser = new ExpressionParser();
// Create a hashtable to hold values
Hashtable h = new Hashtable();
// Add variables and values to hashtable
h.Add( "x", 1.ToString() );
h.Add( "y", 2.ToString() );
// Parse and write the result
double result = parser.Parse( "xcos(y)", h );
Console.WriteLine( "Result: {0}", result );
}
}
|