Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top