You cannot. Access modifiers are there to provide encapsulation for object orientated programming, not for runtime security.
If you need security, you will need to use higher level features.
Pregunta
We can use reflection to get or set value of any private
member in C# class. (using BindingFlags.NonPublic
etc.)
If this is the case, how come private
member is really private? How can we be assured that the things which are purposely stored in the private
fields remain private in true sense?
Solución
You cannot. Access modifiers are there to provide encapsulation for object orientated programming, not for runtime security.
If you need security, you will need to use higher level features.