First, value type and reference type
public static void Main (string[] args) { int = 10;//value type an area in memory that holds an object age1 = age;//The reference type has an address at this point to age The initial address of the age + = 1;//age re-opens the new area at this time for one, Console.WriteLine ("fist=" +age1);//point to the old area value is ten; int age2= (int) age1;/ /reference type conversion value type is ten; Console.WriteLine ("test=" +age2); Age2 + = 1; Console.WriteLine ("Secend=" +age); Console.readkey (); }
Output Results 10 10 11
Second, the successor rewrite
public class program {public static void Main (string[] args) { Employee Yee = new Employee (); Console.readkey (); } } Class person { protected int: age = ten; Public person () {this . Output (); } public virtual void Output () { Console.WriteLine (' Person ' +this.age); } } Class Employee:person {public Employee (): Base () { base.age =; } public override void Output () { Console.WriteLine ("Employee" +base.age); } }
Output Results 10
C # Basic article/Face test