Inheritance
why constructor does not inherit in .net with example
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anil KumarRank #2,740 · 511 reputationPosted Mar 3, 2015, 8:28 AM EST
- When you create the instance of the derived class, it automatically calls the constructor (one without parameter) of the base class.
Now to answer your question :- Constructors are not inherited because we wouldn't be able to properly determine how our derived class objects were instantiated. When all derived classes would use parent's constructors implicitly, in my opinion it would be a problem because if we forgot to redefine constructor, the object might have been initialized incorrectly
Please mark the answer as Accepted if it solves the purpose