Value type: int double char decimal bool enum struct
Reference type: string Array custom Class Collection Object interface
// value passing and reference passing int Ten ; int n2 = N1; - ; Console.WriteLine (N1); // Ten Console.WriteLine (n2); // - Console.readkey ();
If it is a reference type, the last
person P1 =NewPerson ();//This is a reference typeP1. Name ="Zhang San"; Person P2=P1; P2. Name="John Doe"; //P1. Name = "1223";Console.WriteLine (P2. Name);//It's the last 1233 anyway .Console.WriteLine (P1. Name);//It's the last one anyway .Console.readkey ();//John Doe//if there is no P1 here. Name = "1223"; This is Li Shili .
Packing, unpacking
Boxing: Converts a value type to a reference type.
Unboxing: Converts a reference type to a value type.
Look at whether the two types have occurred boxing or unpacking, to see if there is an inheritance relationship between the two types of
Avoidance of unpacking and crating
This place does not take place any type of packing or unpacking
String str = "123";
int n = convert.toint32 (str);//Whether the two types have occurred boxing or unpacking, to see if there is an inheritance relationship between the two types of
int n = 10;
Object o = n;//boxed value type = = Reference type N =>o
int nn = (int) o;//unboxing
C # Base value classes and reference types