質問

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