Should you access a variable within the same class via a Property?

前端 未结 6 2027
攒了一身酷
攒了一身酷 2020-11-29 07:33

If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it.

My question is sho

6条回答
  •  余生分开走
    2020-11-29 07:46

    Always Use Properties, Here are some of the reasons

    1. Easy to Use. In visual Studio you can use "Prop Tab Tab". You will get the property snippet
    2. Properties are language elements that are accessed as though they are data members
    3. .Net framework classes uses it, the data binding code classes in the .NET Framework support properties,
    4. Properties have all the language features of methods. Properties can be virtual

提交回复
热议问题