© { JSL }
41
Text Box: Boxed Solution
Boxed Solution
·when a reference variable binds to a value
wthe runtime copies the value onto the heap
wthe reference refers to the copy on the heap
wthis is called boxing
the copy is the same plain bitwise copy
used for value parameters/returns
struct Pair
{   
    public int X, Y;
    ...
}
static void Function()
{
    Pair p = new Pair(1,2);
    object o = p;
}
p.X
stack
heap
1
2
p.Y
.X
1
2
.Y
@
o
box