0
Why make a private property?
Why make a property private if the private field that it accesses can already be accessed from within the class? EDIT: This is my understanding. Some fields should not be made directly accessible from outside the class, and hence they are made private. A public property is therefore required to access this private field (indirectly) from the outside. However, by making the property private, this can only be accessed from inside the class. But then whatever is accessing this private property (from within the class) should also be able to access the private field directly. Therefore, what is the purpose of this private property?
3 Antworten
0
when making a property primary, ita cannot be accessed outside the class.
0
how to include a javascript intp html?
0
The purpose of the private property is to not make it directly usable outside of the class they are in. It is usually ment for protection of certain parts of your code because we don't want the user to have access to it directly.