[C #] C # knowledge Review,
Packing and unpacking directory
- Packing and unpacking in life
- C # packing and unpacking
- Value Type and reference type
- Packing
- Unpack
Packing and unpacking in life
We are used to online shopping. This time you want to buy a programming book, "C language from getting started to giving up". After the order is successfully placed, the seller will pack this guide, we can call it packing. The package will be delivered directly to you after the courier's fast whip, rain or shine. You will surely be able to unassemble the package with the treasure of the bell, which we can call as a box-breaking process. At this time, the guide will be delivered to you smoothly.
Static void Main (string [] args) {var I = 123; // System. int32 // pack (implicit) object obj = I; // unpack (explicit) obj I = (int) obj; Console. read ();}
Here, I will first change the variablei
(Int type) is boxed and allocated to the objectobj
. Second, unpack the object obj again (strong conversion) and re-assign the variableI (int type) value assignment.
Array, user-defined classes, interfaces, delegation, objects, strings, etc.
(3) Simple stack diagram:
Figure: @ indicates a reference address
Packing
Packing is an implicit conversion process (explicit) implemented by the value type to the object type or the interface type implemented by the value type ). When packing, an object instance is automatically created in the heap, and the value is copied to the new object.
Var I = 123; // System. Int32 // pack (implicitly) I into the object o = I;
Int I = 123; // value type object o = I; // binning int j = (int) o; // unpack
C # basic Review Series
C # knowledge Review-serialization
C # knowledge Review-Expression Tree Expression Trees
C # knowledge Review-feature Attribute and AssemblyInfo. cs-understanding common feature attributes
C # knowledge Review-delegated delegate and C # knowledge Review-delegated delegate (continued)
C # knowledge Review-Introduction to events and C # knowledge Review-Event Events
There is no unspeakable secret between the string, the String, the big S, and the small S
C # knowledge Review-do you really understand exceptions?
Have you ever understood the entry function Main? Using batch processing to convert the Main function
C # basic review-anonymous method
Looking back at the past and present of C #-witness the new syntax features of c #6.0
「 If you don't want to spend your life in the world, you have to learn for a lifetime .」 -- Gorky
[Blogger] Anti-Bot
Http://www.cnblogs.com/liqingwen/p/6486332.html.