Override get, But not set

前端 未结 13 2445
暖寄归人
暖寄归人 2020-12-14 14:17

I have an abstract class that defines a get, but not set, because as far as that abstract class is concerned, it needs only a get.

13条回答
  •  萌比男神i
    2020-12-14 15:02

    One possible answer would be to override the getter, and then to implement a separate setter method. If you don't want the property setter to be defined in the base, you don't have many other options.

    public override double MyPop
    {
        get { return _myPop; }
    }
    
    public void SetMyPop(double value)
    {
        _myPop = value;
    }
    

提交回复
热议问题