Question about boxing in C#
Posted on 2014-07-30
If you box a value-type variable, do you delete that variable from the stack? For example, suppose you declare an Integer variable named myInteger. This puts myInteger on the stack. If you box myInteger, you create a reference-type version of myInteger in the heap. In doing so, have you created two copies of myInteger as shown below?
1st Copy: value-type copy of myInteger on the stack
2nd Copy: reference-type copy of myInteger in the heap
Or does the original myInteger on the stack get deleted automatically when you box it?