1

Possible Duplicate:
Why use simple properties instead of fields in C#?

If I have a class, does it matter if I use a Variable instead of a Property? I mean, unless I need something to run during the get/set time period, does it really matter? It still gets the job done.

Community
  • 1
  • 1
Freesnöw
  • 30,619
  • 30
  • 89
  • 138

1 Answers1

1

It doesn't necessarily "matter" which you do. The reason for using property get/set would be to validate values before they're assigned to the variable and ensure that it can't be directly accessed from outside the class.

If you only have a small application and your class won't be designed to be reusable, I don't see a problem with just using public variables.

ChrisO
  • 5,068
  • 1
  • 34
  • 47