Syntax Error: unexpected character ',', on line: 1 column: 9

May 12, 2008 at 1:24 PM
Edited May 12, 2008 at 1:28 PM
I want to extend Math class with simple function. My code look like:

namespace 
MyNamespace
{
        public static class BHMath
         {
             public static double PDiv(double a1, double a2)
                        {
                            if (a2 == 0)
                               return 1.00;
                           
else
                              
return a1/a2;
                          }
         }
}

Then code looks like:

1: ExpressionContext context = new ExpressionContext();
2: context.Imports.AddType(typeof(BHMath));
3: context.Variables.Add("a1", 1.0);
4: context.Variables.Add("a2", 2.0);

5: IDynamicExpression e = ExpressionFactory.CreateDynamic("PDiv(a1,a2)", context);
6: double result = (double) e.Evaluate();

Exception occurs IN LINE 5: -  Syntax Error: unexpected character ',', on line: 1 column: 9

please help !

thank you.

 

 

 

 

 

May 12, 2008 at 1:32 PM
Sorry, this is culture issue. I found the solution in issue tracker.
thank you