Demonstrate when constructors are called : Class Inheritance : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Class Inheritance »

 

Demonstrate when constructors are called









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Demonstrate when constructors are called. 
 
using System; 
 
// Create a base class. 
class A { 
  public A() {  
    Console.WriteLine("Constructing A."); 
  } 
} 
 
// Create a class derived from A. 
class B : A { 
  public B() { 
    Console.WriteLine("Constructing B."); 
  } 
} 
 
// Create a class derived from B. 
class C : B { 
  public C() { 
    Console.WriteLine("Constructing C."); 
  } 
} 
 
public class OrderOfConstruction { 
  public static void Main() {
    C c = new C(); 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Class Inheritance