Math Parser for .NET
Class Hierarchy
This inheritance list is sorted roughly, but not completely, alphabetically:
[detail level 12]
 CBestcode.MathParser.IFunctionIFunction interface represents a user defined callback function that takes n parameters. During evaluation of an expression, MathParser calls

IFunction.Run(IParameter[] p)

to request the value of the function when it takes parameters listed in p.

For example, a user could define a function like this:

public class MyFunc implements IFunction {
   public IConvertible Run(IParameter[] p){
     return do_something_with_params( p );

   public int GetNumberOfParams(){
     return 3;

Another user defined function "if" could be used as "if(1,3,4)". In this case, implementation of IFunction.Run(IParameter[]) could return 3.0 if first parameter is >0 and it could return 4.0 if first parameter is 0 (false, to mimic "if" behavior).

 CBestcode.MathParser.OneParameterFuncBase class for math parser functions that take 1 parameter.
 CBestcode.MathParser.TwoParameterFuncBase class for math parser functions that take 2 parameters.
 CBestcode.MathParser.ZeroParameterFuncBase class for functions that take no parameter.
 CBestcode.MathParser.IParameterIParameter is used to supply a parameter value for a user defined function. The actual value may be calculated from a complicated sub expression. The value is not computed until you call the IParamater.GetValue() function(s). If you are going to use the value more than once, it is best to cache it in a local variable. The value can be numeric (DOUBLE_PARSER) or a String. If the string can be parsed as a double, then you can still call GetValueAsDouble on it and an automatic conversion will take place. All functions take an array of IParameter[] that enables them to query the current value of the parameters using the GetValue(), GetValueAsDouble() or GetValueAsString() functions.

For most functions such as sin(x), cos(x) etc the length of IParameter[] p is 1. For some functions such as min(x,y), the length of IParameter[] p is 2. The built in IF(a, b,c) function has IParameter[] p length 3. The build in RDN() function has IParameter[] p length 0. For functions such as SUM(...) or CONCAT(...) the p.length (number of parameters that the function is taking) is determined at runtime. It can be 0 or more. See IFunction interface to learn more about defining functions and their parameter lengths. Example:

public IConvertible Run(IParameter[] p) {
double x__ = p[0].GetValueAsDouble();
return (Math.Exp(x__)+Math.Exp(-x__))*0.5;
br /> /summary>
 CBestcode.MathParser.NodeSupport class that represents generic node, base for all nodes.
 CBestcode.MathParser.ParserExceptionParserException is thrown by some methods of MathParser implementation if an expression cannot be parsed. These methods are: Parse(), Evaluate(), GetValue() /summary>
 CBestcode.MathParser.StandardLibA holder for the standard math parser functions.
 CBestcode.MathParser.MathParserMathParser class calculates the value of mathematical expressions given as strings at runtime. Expression can contain predefined or user defined variables and functions.
 CBestcode.MathParser.StrUtilBasic String utilities.