Are 2 and 3 examples of boxing / unboxing?
1) Example documentation:
int i = 123;
object iBoxed = i;
i = (int) iBoxed;
2: Also have boxing / unboxing?
int i = 123;
object iBoxed = i;
i = Int32.Parse(iBoxed.ToString());
3: Also have boxing / unboxing?
int i = 123;
object iBoxed = i;
i = Convert.ToInt32(iBoxed);
I assume that in all examples the same thing happens technically.
- Value type is created on the stack
- A link is created on the stack, the value is copied to the heap.
- The heap value is copied to the link. The link is deleted.
So, I think 2 and 3 are examples for boxing / unboxing?
source
share