When declaring a parameter expression, for example:
ParameterExpression x = Expression.Parameter(typeof(double),"x");
You can then use this parameter to construct Lambda expressions:
Expression Lowerbound = Expression.Constant(0.0,typeof(double));
Expression GreaterThanorEqual = Expression.GreaterThanOrEqual(x, Lowerbound);
Expression TestExpression = Expression.Lambda(GreaterThanorEqual,x);
Console.WriteLine(TestExpression.ToString());
// returns x => (x >= 0)
I now need a way to construct expressions of the form
x => (x[0] >= 0)
x => (x[1] >= 0)
x => (x[2] >= 0)
... et cetera
I cannot, however, find a way to define a parameter
Expression.Parameter(typeof(double[]),"x");
array as one Parameter
and then
Expression.Parameter(typeof(double),"x["+i+"]");
As another
is there a way to define a Parameter that has a Type of double[] ?
Parametercall should work, are you asking how to construct the index expression?Expression.ArrayAccess(xParam, Expression.Constant(0))should work.