Skip to main content

Posts

Showing posts with the label constructor calling in inheritance

Best Use of C# Constructors In Inheritance [How To]

Question : We have two classes,one is ClassA and other is ClassB, the ClassB inherit base class ClassA. If we make the object of child class ClassB then which class constructor called first? //We have two classes, one is ClassA and other is ClassB, the ClassB inherit base class ClassA. //If we make the object of child class ClassB then which class constructor called first? namespace ConsoleNamespace {     class ClassA     {         public ClassA()         {             Console .WriteLine( "ClassA::Constructor()" );         }     }     class ClassB : ClassA     {         public ClassB()         {         ...