All pastes #116384 Raw Edit

Unnamed

public text v1 · immutable
#116384 ·published 2006-08-05 06:54 UTC
rendered paste body
 // Inheritance : constructor chaining
// Author: rajeshvs@msn.com
using System;
class Base
{
            public Base()
            {
                        Console.WriteLine("Base constructor1");
            }
            public Base(int x)
            {
                        Console.WriteLine("Base constructor2");
            }
}
class Derived : Base
{
            public Derived() : base(10)// implicitly call the Base(int x)
            {
                        Console.WriteLine("Derived constructor");             
            }
}
class MyClient
{
            public static void Main()
            {
Derived d1 = new Derived();// Displays 'Base constructor2 followed by 'Derived Constructor''
            }
}