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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top