We have seen that the public keyword is used to let objects of the same program and objects of other programs access the public member. The private keyword is used to let only members of a class access the (private) member of the class. If you want to create a member of a class so that only objects of the same program can access that member, you can mark it with the internal keyword. The differences between these keywords can be resumed as follows:
| If a class member is marked as | |||
| public | private | internal | |
| Members of its class can access this member | Yes | Yes | Yes |
| Members of this program, including outside of the class, can access this member | Yes | No | Yes |
| Objects outside of this program can access this member | Yes | No | No |
本文详细介绍了在编程中如何使用public、private及internal等访问修饰符来控制类成员的可见性。通过对比这些关键字的不同,帮助读者理解它们在不同场景下的应用。

2045

被折叠的 条评论
为什么被折叠?



