Best Practice on local use of Private Field x Property

后端 未结 9 1688
萌比男神i
萌比男神i 2021-01-22 02:09

When inside a class you have a private fiels and expose that field on a public property, which one should I use from inside the class?

Below you is an example on what I

9条回答
  •  灰色年华
    2021-01-22 02:55

    I always use the property accessors, because the I am safe in case I add logic in the getter or setter in the future, knowing for sure that no code bypasses it.

提交回复
热议问题