Override get, But not set

前端 未结 13 2468
暖寄归人
暖寄归人 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条回答
  •  青春惊慌失措
    2020-12-14 14:51

    EDIT:

    OK I may have been hasty with this response, but I've given it some more thought now.

    Do you have to use an abstract base class? If it's not required, try this:

    public interface ISomeRelevantName
    {
        double MyPop { get; }
    }
    
    public class DClass : ISomeRelevantName
    {
        public double MyPop { get; set; }
    }
    

提交回复
热议问题