I have a base class and derived class. If I’m creating an object of the derived class, which constructor will be taken first: the base constructor or the derived constructor?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The instance constructors are initialize in reverse order. The base constructor will be initialized first, then the derived constructor.
Take a look here http://www.csharp411.com/c-object-initialization/
There is a good overview of the order in which the object’s fields and constructors are initialized: