- constructors are called in the order from the top to the bottom (parent to child class) in inheritance hierarchy.
class parent { public parent() { Console.WriteLine("This is Paarent"); } } class child : parent { public child() { Console.WriteLine("This is child"); } } class Program : child { static void Main(string[] args) { Program obj = new Program(); Console.Read(); } public Program() { Console.WriteLine("This is program"); } } Output: This is Paarent This is child This is program |
No comments:
Post a Comment