Getter without body, Setter with

后端 未结 5 650
死守一世寂寞
死守一世寂寞 2021-01-01 11:21

I have a property which is currently automatic.

public string MyProperty { get; set; }

However, I now need it to perform some action every

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 12:02

    This is similar to the question C# getter and setter shorthand.

    When you manually specify a setter, it won't use the automatic property mechanism for the getter, which is why the error message acts like it's missing. You'll need to write your own getter when you specify the setter.

提交回复
热议问题