Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReflectedType from MemberExpression

Tags:

Given this code:

static void Main(string[] args)
{
    Expression<Func<SomeDerivedClass, object>> test = i => i.Prop;
    var body = (UnaryExpression) test.Body;
    Console.WriteLine(((MemberExpression) body.Operand).Member.ReflectedType);
}

public class SomeClass
{
    public int Prop { get; private set; }
}

public class SomeDerivedClass : SomeClass
{
}

I would have expected ReflectedType to be SomeDerivedClass given that it is the type of the parameter for the expression. But it is SomeClass, which is - if i understand correctly - the declaring type.

Why is that?