C#C
C#3mo ago
Faker

✅ Importance of getters and setters

Hello, can someone explain the importance of getters and setters in programming please.

I know with setters, we can check for conditions, like if age < 18, then do something but apart from that, why do we force devs to make use of setters/getters?


for e.g consider: person.name = "John"

why is name a private property. Why force us to use a setter instead of just making name public?
Was this page helpful?