© { JSL }
41
Boxed Solution
·
when a reference variable binds to a value
w
the runtime copies the value onto the heap
w
the reference refers to the copy on the heap
w
this 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