【www.gdgbn.com--php常用代码】

对于引用类型,clr可以通过在堆中的typehandle找到其对应的methodtable,进而定位到此类型的方法代码,编译并执行之。然而值类型是分配在栈上,并没有typehandle,它是如何找到方法表的?

  。。。

public class mystruct

{

  private int a;

  private int b;

  public void mymethod()

  {

    ...

  }

}

public static void main()

{

  mystruct m=new mystruct();

  m.tostring();//通过装箱获得方法表,执行方法。

  m.mymethod();//此处不会装箱,但如何找到方法表?

}

 

本文来源:http://www.gdgbn.com/jiaocheng/29264/