If an interface defines a ReadOnly Property, how can an implementer provide the Setter to this property?

前端 未结 5 1092
北恋
北恋 2021-01-18 04:51

Is there a way for implementers of an interface where a ReadOnly property is defined to make it a complete Read/Write Property ?

5条回答
  •  遥遥无期
    2021-01-18 05:07

    You can't do it as the interface requires that you implement a ReadOnly Property.

    Properties don't allow overloading so there is no way to implement a non-ReadOnly and also a ReadOnly.

    I would suggest you either implement a Custom Setter or drop the ReadOnly from the Interface.

    Without details of why you want to do this it is hard to suggest the best solution

提交回复
热议问题