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 |