I understand how to use properties.

What I would like to know is...

Properties are designed to stop direct access to an variable

Can anyone give an example where if the property was not used and the variable was written to directly..this would cause a problem?

Thanks
James

Easy. Suppose you have an Employee class(yes that one again) with an Age property. In the set part of the property you could check if the age is between 18 to 60, or whatever.

Thanks ddanbe..that makes sense..I didn't think of it that way..but I see what you are saying...

I suppose it is always better to use them than not use them!

Well said! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.