At the outset, let me say that I have seen a sort of solution for the problem, but I found this this is majorly used for testing purpose only.
Could anyone give me a good practice way of calling a internal class's internal static property from the external assembly in C#?
I would appreciate if anyone can give me a small example in C#. I am aware of using "AssemblyVisibleTo" but I was told that it is not a good way to code.
There are three ways to access internal
data (whether static or not):
internal
as you now have external code that is directly dependent on the internal implementation InternalsVisibleTo
Attribute - you have been told that this is "not a good way to code", which most would agree with, however you were not given an alternative (hence your question). This has bacically the same drawbacks as reflection (it just makes the client code cleaner). So propose those three alternatives to your client and see which they prefer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.