Properties vs Methods

后端 未结 16 1685
傲寒
傲寒 2020-11-22 08:23

Quick question: When do you decide to use properties (in C#) and when do you decide to use methods?

We are busy having this debate and have found some areas where it

16条回答
  •  悲哀的现实
    2020-11-22 08:27

    If you're setting an actual property of your object then you use a property.

    If you're performing a task / functionality then you use a method.

    In your example, it is a definite property being set.

    If however, your functionality was to AppendToLabel then you would use a method.

提交回复
热议问题