How to access a private data members of base class in the derived class?
Since we can access the private data member of base class in the derived class with the help of friend function. How can we do the same in C# asp.net? I mean whats the alternative of friend function i开发者_开发百科n C# asp.net?
internal
is the access modifier for stuff that needs tobe accessible in a single assembly. protected
is the modifier to get access to base class stuff.
If you have no control over the base class and need to 'hack' access, NHibernate does that sort of thing, e.g. when creating a performant setter on private instance fields. In this case the source code of the method NHibernate.Bytecode.Lightweight.ReflectionOptimizer.GenerateSetPropertyValuesMethod
could be of interest to you.
You could use reflection... this might give you a start...
How do I use reflection to invoke a private method?
精彩评论