0

What is the different between property and a Field

I mean aren't they all declared at the Class Code block

13th May 2018, 11:43 PM
Mohammed Orif
Mohammed Orif - avatar
1 Réponse
+ 1
It is actually very simple. A field is used within your own class and a property is accessed outside of it. When declaring an field you will see it is private and an property is public. This follows the principles of OOP and encapsulates your data. When making you constructor and to strings you should always use your properties otherwise you are breaking the rules of OOP and rendering properties futile which it is not.
28th Jun 2018, 7:41 PM
Megan Venter
Megan Venter - avatar