How to get the parameters in a given expression?

Topics: Help
Jul 4, 2012 at 2:48 PM

I've searched in the discussions but I can't find an answer to this.

Is there a way to get a list of parameters in a given expression?


Expression ee = new Expression("[a] * [b] + 10",EvaluateOptions.IterateParameters);
Dictionary<string,object> p =  ee.Parameters;
Console.WriteLine(p.Count); // this return zero parameters

foreach (var result in (IList)ee.Evaluate()) {
      Console.WriteLine(result); // never enter here, before evaluate ee.Parameters still are zero

Using NCalc Version 1.3.8
Jul 4, 2012 at 4:00 PM

You can get the parsed expression tree without evaluating the expression. Then you can navigate it and search for parameters.