struct Point
{
public int x;
public int y;
}
void Main()
{
Point p;
p.x = 1;
p.y = 1;
Object o = p;
((Point) o).x = 4; // error
((Point) o).x = 5; // error
((Point) o).x = 6; // error
p = (Point) o // expect 6
}
为什么不编译成
ldloc.1 // o
unbox Point
ldc.i4.4
stfld Point.x
C++ CLI 允许的地方。