https://www.cnblogs.com/Bear-Study-Hard/archive/2006/01/09/313551.html
Read the above article felt, do a little special model, in order to deepen this understanding in a derived class
. 1 the using the System; 2 the using the System.Collections.Generic; . 3 the using the System.Linq; . 4 the using the System.Text; . 5 the using System.Threading.Tasks; . 6 . 7 namespace ConsoleApp77 . 8 { . 9 public class MyBaseClass 10 { . 11 public MyBaseClass () 12 is { 13 is Console.WriteLine ( " I is a base class, no argument constructor! " ); 14 } 15 16 publicMyBaseClass ( int I) . 17 { 18 is Console.WriteLine ( " I is the base class, there are parameters, parameter 0} { " , I); . 19 } 20 is } 21 is 22 is public class MyDerivedClass: MyBaseClass 23 is { 24 public MyDerivedClass (): the this ( . 5 , . 6 ) 25 { 26 is Console.WriteLine ( " I am a derived class, no argument constructor! " ); 27 } 28 29 publicMyDerivedClass ( int I) 30 { 31 is Console.WriteLine ( " I derived class has a constructor parameter, the parameter: {0} " , I); 32 } 33 is 34 is public MyDerivedClass ( int I, int J) 35 { 36 Console .WriteLine ( " I derived class has a constructor parameter, the parameter: {0}, {}. 1 " , I, J); 37 [ } 38 is } 39 40 class Program 41 is { 42 is static void the Main (string[] args) 43 { 44 MyDerivedClass myder = new MyDerivedClass(); 45 } 46 } 47 }
This code performs the following sequence:
1. Performing System.Object.Object () constructor.
2. Performing MyBaseClass.MyBaseClass () constructor.
3. Performing MyDerivedClass.MyDerivedClass (int i, int j) constructor.
4. Performing MyDerivedClass.MyDerivedClass () constructor.