How to describe "return ref" in expression tree?

105 Views Asked by At
Func<T, TField> GetFunc<T, TField> (this FieldInfo fieldInfo) {
      var instanceParameter = Expression.Parameter (typeof (T), "instance");
      var fieldExpression = Expression.Field (instanceParameter, fieldInfo);
      var lambda = Expression.Lambda<Func<T, TField>> (fieldExpression, instanceParameter);
      return lambda.Compile ();
}

I wrote this method to get this lambda expression.

return (T instance) => instance.[fieldInfo.Name];

But how do I write the method to get this lambda expression?

return (T instance) => ref instance.[fieldInfo.Name];
0

There are 0 best solutions below