Let's say I have an expression like this:
Expression<Predicate<T>> exp
If I assign the following expression:
a => a.First() != 0
and then I call exp.ToString()
I will obtain exactly the expression I passed, that is perfectly good, but, suppose we want to change the name we use for 'a' with something else, how can we do ?
String replacement would not do in all the case ( it works in the example above,but what if the parameter was called 'i' for example ?)
Is it possible to have just the parameter name replacement, run time, without affecting the expression semantic ?
UPDATE The @PhilKlein works perfectly, but requires framework 4. But if we need to target the framework 3.5 we can use an ExpressionVisitor class from Matt Warren, by just modifing from protected to public the Visit method.