Why using only setter in property declaration?

后端 未结 4 580
北荒
北荒 2021-01-26 09:32
int MyProperty { set; }

What\'s the idea for using only setter on property? If we set one property with some value, I guess it\'s very likely to read t

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-26 09:56

    A method would make much more sense than a 'write only property' - even if the code did compile. There is an interesting discussion around write only proprties Here

提交回复
热议问题