Parent child relationship
Which constructor fires first in the case of parent child relationship?
3 Answers
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
SenthilkumarRank #387 · 6.5K reputationPosted Mar 25, 2012, 8:57 PM EDT
If you see this example
The base class will be executed first and then super class next.
Dipal ChoksiRank #199 · 12K reputationPosted Mar 25, 2012, 8:59 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 25, 2012, 10:43 PM EDT
First invoke base class constructor and then after derived class constructor
example.
class A
{
public A()
{
}
public A(string d)
{
}
}
class B : A
{
public B(string f) : base(f)
{
}
public B()
{
}
}
when I create
B b =new B("mystring");
first this will call A(String) method and then B(String).
hope this help.