I’ve been learning C# for a while now, and I’ve come across properties in my C# book (Head First C#). I honestly do not understand what they’re used for, and why I should use them. I’ve googled them a few times but still cannot for the life of me understand them.
Can someone please explain to me this foreign concept?
Thanks,
Varmitharen
Properties are used to enrich the Encapsulation concept of Object-Oriented Programming.
i.e. They encapsulate a field-member and let you (the developer) control how setting/getting this variable is done. Example?
See? using property
Age, we guaranteed that the minimum set value of age is 18.