This is a followup to this question: Lambda expression not returning expected MemberInfo
class Human
{
public string name { get; set; }
}
class Man : Human
{
}
var m1 = typeof(Human).GetProperty("name");
var m2 = typeof(Man).GetProperty("name");
//m1 != m2 why?
The same holds for MethodInfo
s.
I can understand there has to be a difference when Human
is an interface, or when name
of Human
is abstract/virtual. But why is it so for sealed types? Isn't name
of Man
exactly name
of Human
?
Clarification: As Jon says their ReflectedType
s are different. ReflectedType
in equality should come handy when deciding equality of interface members or overridden members since they are different. But I don't think it should be considered for deciding equality of simple cases like above. May be the design team wanted to be consistent. Just wondering what rationale drove framework designers to consider ReflectedType
property in deciding equality of same member spanning over multiple classes.