c# - How to read out protected member -


i want access protected member in class. there simple way?

there 2 ways:

  1. create sub-class of class protected members want access.
  2. use reflection.

#1 works if control creates instances of class. if already-constructed instance being handed you, #2 viable solution.

personally, i'd make sure i've exhausted other possible mechanisms of implementing feature before resorting reflection, though.


Comments