假设我有以下内容:
我该如何使用表达式树来重写fnSet的定义,例如:
class Foo {
public int Bar { get; set; }
}
public void SetThree( Foo x )
{
Action<Foo, int> fnSet = (xx, val) => { xx.Bar = val; };
fnSet(x, 3);
}
我该如何使用表达式树来重写fnSet的定义,例如:
public void SetThree( Foo x )
{
var assign = *** WHAT GOES HERE? ***
Action<foo,int> fnSet = assign.Compile();
fnSet(x, 3);
}