Given:
FieldInfo field = <some valid string field on type T>; ParameterExpression targetExp = Expression.Parameter(typeof(T), 'target'); ParameterExpression valueExp = Expression.Parameter(typeof(string), 'value');
How do I compile a lambda expression to set the field on the ‘target’ parameter to ‘value’?
.Net 4.0 : now that there’s
Expression.Assign, this is easy to do:.Net 3.5 : you can’t, you’ll have to use System.Reflection.Emit instead: