c# - Getting non-public properties of a type via reflection -
how can non-public properties of type via reflection?
yes, can. specify bindingflags.nonpublic
in call getproperties()
.
class program { static void main(string[] args) { var f = new foo(); foreach (var fi in f.gettype().getproperties( bindingflags.nonpublic | bindingflags.instance)) { console.writeline(fi); } } } public class foo { private string prop { get; set; } }
Comments
Post a Comment