Why can't we use a constructor with parameter in derived classes

前端 未结 3 1891
感情败类
感情败类 2021-01-15 20:31

Why is this not possible? I get the following compiler-error when instantiating \"DerivedClass\" with a constructor-parameter:

\'GenericParameterizedConstructor.Deri

3条回答
  •  梦谈多话
    2021-01-15 20:35

    The deriving class needs to expose the constructor

    public class DerivedClass : BaseClass
    {
        public DerivedClass(string str) :base(str) {}
    }
    

提交回复
热议问题