When it comes to packing and unpacking, it is necessary to summarize briefly what is packing and unpacking,
Boxing: The value type is actually converted to a reference type.
Unpacking: In fact, the reference type is converted to a value type.
Value types: generally include int char bool double datetime and so on these, value types are stored inside the stack
Reference type: The reference type includes the object class Interface Delegate string Arry Dynamic, the reference type is stored in the heap, and the memory address is generally contiguous.
Boxing is the conversion of a value type to a reference type
int i = 12;
Object obj = i;
Unpacking is the conversion of a reference type to a value type
i = (int) obj;
Packing and unpacking are more consumption performance, can avoid such behavior as far as possible.
String STR3 = "123";
int i4 = 4;
Console.WriteLine (STR3+I4);//This boxing behavior will affect the efficiency, how to avoid, the following method
Console.WriteLine (Str3+i4. ToString ());//This is a way to improve point efficiency.
Console.readkey ();
. NET Boxing unpacking