4

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?

4

1 回答 1

2

你不能。访问修饰符用于为面向对象的编程提供封装,而不是为了运行时安全。

如果您需要安全性,您将需要使用更高级别的功能。

于 2013-10-21T09:06:48.257 回答