By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,046 Members | 1,775 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,046 IT Pros & Developers. It's quick & easy.

Why abstract class allows to create a constructor if it cannot be instantiated in C#?

P: 1
I am learning C# and I recently come to know that we cannot instantiate the abstract class which is fine. But the main question is, if it cannot be instantiated, then why does it allow to create a constructor?
2 Weeks Ago #1
Share this Question
Share on Google+
1 Reply

P: 77
Abstract classes cannot be instantiated because abstract methods have no body, so they will make the program to stop at run-time if an object calls any of such methods.

Constructors are allowed because of the concept of inheritance. Abstract classes can be inherited. And to initialize the child class' objects, constructor is to be called. But before calling its own constructor (child class constructor), parent class constructor is called first (refer to the rules of inheritance).
2 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.