.net - PropertyInfo.GetSetMethod(true) not returning method for properties from base class -
i have following test program:
public class foobase { public object prop { { return null; } private set { } } } public class foo :foobase { } class program { static void main(string[] args) { methodinfo setmethod = typeof(foo).getproperty("prop").getsetmethod(true); if (setmethod==null) console.writeline("null"); else console.writeline(setmethod.tostring()); console.readkey(); } } and shows "null" if run it. if move property definition class foo works expected. bug in .net?
this design. foobase property setter not accessible in foo class, no matter try:
public class foo : foobase { void test() { prop = new object(); // no ((foobase)this).prop = new object(); // no } } you'll have use typeof(foobase).getproperty("prop") in code.
Comments
Post a Comment