So without using extensions of the class we have apparently two options:
1- Overlayering (Will not be available after Update 14 as per Microsoft)
2- Reflection
Reflection is usually used for unit testing in case you need to cover protected or private code and it is hard to call this code using public API.
It has some disadvantages:
1- It breaches entire basis of Object oriented programming.
2- Slow performance.
3- Possible issues with future updates. Private methods could be changed at any time.
However, once you may get into situation where it could be the only option so it’s better to know about this possibility. In below mention images shows how we can use private
variable by reflection technique.
OOTB Class:
Using reflection namespace:
Get private member:
Hi Tabsheer, I am going to update a private member by reflection, do you know anyway to do that? Thanks & Regards.
ReplyDelete