Google+

Friday, December 24, 2010

Answer of Question : How to call a default constructor inside a default constructor

in below example , we make an object of A using the Constructor of B Class.
First default constructor of class A called then CLR call default constructor of class B ,then make the object of class A .

public class A


{ public A()

{  Console.WriteLine("A"); }

}

public class B:A

{ public B()

{ Console.WriteLine("B"); }

}

class Program

{ static void Main(string[] args)

{

 A ob = new B();

}

}

output
A
B


Note:-Please comment and reply me.

0 comments:

Post a Comment