Is there any mechanism for youyuan in the C # language?
Is there a way to expose some internal members of a class to only one other class?
A:
C # There are no friends functions and friends class. In C ++, the user meta function and user Meta class are not necessary. They are used to improve efficiency (accessing internal members is faster than accessing external members, so encapsulation is not considered, (c) With the improvement of hardware performance, the role of youyuan is insignificant, but it destroys the class encapsulation, so this feature is removed in Java, C # also removes this feature.
This design of the hosting environment should also have its own principle, which can eliminate unnecessary coupling and break the class encapsulation. Youyuan is against Oo, and the hosting environment il does not support
Internal. This attribute indicates that the class and Members can only be used in the current program. In some ways, they are similar to friends.
Class friends, function friends are generally not used, can be replaced by public, and then encapsulated in the Assembly with internal, but friends can be used in the assembly, therefore, C #2.0 adds this function (implemented using attribute)