What is the benefit of a bool property that just gets and sets a bool?
I know the benefit of only a get property or decisions that need to be made before you set a bool. I've seen examples using just get/set. I don't get it. What harm could making the bool variable public do?
(You can set it to null instead of a value, but you can do the same thing in a property if you don't check if value != null.)
kplcjl
17
Junior Poster
Recommended Answers
Jump to Postpublic variables are not thread safe, the get and set properties make sure that a variable isn't in use by locking it temporarily an if is locked, causing a pause to occur until it is free. Its just the preferred way the framework handles variable access. with a simple bool …
All 3 Replies
Diamonddrake
397
Master Poster
kvprajapati
1,826
Posting Genius
Team Colleague
kplcjl
17
Junior Poster
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.