public static MemberExpression Expression.Property(Expression expression, MethodInfo property)
Instead prefer
public static MemberExpression Expression.Property(Expression expression, PropertyInfo property)
Tiny notes from everyday work. Mostly about .NET, C# and some tools I use every day.
public static MemberExpression Expression.Property(Expression expression, MethodInfo property)
public static MemberExpression Expression.Property(Expression expression, PropertyInfo property)
class Foo
{
public int Bar{get;set;}
}
What is the result of the following code execution?
var property = typeof(Foo).GetProperty("Bar");
Foo foo = new Foo {Bar = 5};
property.SetValue(foo, null, null);
Console.WriteLine(foo.Bar);void SetValue(object instance, object value)
{
}
The method should set the given value to the specified property in the instance object. Property should be specified by its PropertyInfo.