The following are my codes:
class Foo { public string Bar { get; private set; } }
and
var prop = typeof(Foo).GetProperty("Bar"); if (prop != null) { // The property exists var setter = prop.GetSetMethod(true); if (setter != null) { // There a setter Console.WriteLine(setter.IsPublic); } }
yes, as you can imagine, this works perfectly right. but when the inheritance comes, everything is different:
class Foo { public string Bar { get; private set; } } class A : Foo { }
Of course, I changed this line:
var prop = typeof(Foo).GetProperty("Bar");
to
var prop = typeof(A).GetProperty("Bar");
then the installer gets null and the console doesn't print anything!
So why?
btw, is there any workaround to make this happen or be in a completely different way?
Any help would be appreciated. thanks.
source share