Exposing Member Objects As Properties or Methods in .NET

后端 未结 7 1943
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 05:58

In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?

7条回答
  •  有刺的猬
    2020-12-05 05:59

    That is irrelevant to the matter.

    It should be a Property if the value is some detail about the state of the object.

    It should be Method if it performs some action on the object.

提交回复
热议问题