日期:2014-05-20  浏览次数:21179 次

关于.NET 中间语言问题,高手请不要错过 ,比较长,需要细心才能看完
主:   本文的代码内码   地址在:http://blog.vckbase.com/zhaotide/archive/2004/11/06/1316.aspx
我在学习这篇文章的时候遇到了一个不解的地方,请高手帮忙,谢谢.
代码如下时:
    namespace   ConsoleApplication1
{
///   <summary>
///   Class1   的摘要说明。
///   </summary>
class   Class1
{
///   <summary>
///   应用程序的主入口点。
///   </summary>
[STAThread]
static   void   Main(string[]   args)
{
//
//   TODO:   在此处添加代码以启动应用程序
//
MyDerived   mD   =   new   MyDerived();

MyBase   mB   =   (MyBase)   mD;
// MyBase   mB   =   new   MyBase();


System.Console.WriteLine(mD.Meth1());

System.Console.WriteLine(mD.Meth2());

System.Console.WriteLine(mD.Meth3());

System.Console.WriteLine( "以上为类MyDerived的显示结果!\n ");

System.Console.WriteLine(mB.Meth1());

System.Console.WriteLine(mB.Meth2());

System.Console.WriteLine(mB.Meth3());

System.Console.WriteLine( "以上为MyBase的显示结果!\n ");


System.Console.WriteLine( "按任意键退出... ");

System.Console.ReadLine();


}
}
public   class   MyBase  

{

public   virtual   string   Meth1()  

{

return   "MyBase-Meth1 ";

}

public   virtual   string   Meth2()  

{

return   "MyBase-Meth2 ";

}

public   virtual   string   Meth3()  

{

return   "MyBase-Meth3 ";

}

}


class   MyDerived   :   MyBase  

{

//   使用   override   关键字重写虚方法   Meth1:

public   override   string   Meth1()  

{

return   "MyDerived-Meth1 ";

}

//   使用   new   关键字显式隐藏

//   虚方法   Meth2:

public   new   string   Meth2()  

{

return   "MyDerived-Meth2 ";

}

//   由于下面声明中没有指定任何关键字

//   因此将发出一个警告来提醒程序员

//   此方法隐藏了继承的成员   MyBase.Meth3():

public   string   Meth3()  

{

return   "MyDerived-Meth3 ";

}
}


}
main中间语言为:
    .method   private   hidebysig   static   void     Main(string[]   args)   cil   managed
{
    .entrypoint
    .custom   instance   void   [mscorlib]System.STAThreadAttribute::.ctor()   =   (   01   00   00   00   )  
    //   Code   size               111   (0x6f)
    .maxstack     1
    .locals   init   ([0]   class   ConsoleApplication1.MyDerived   mD,
                      [1]   class   ConsoleApplication1.MyBase   mB)
    IL_0000:     newobj           instance   void   ConsoleApplication1.MyDerived::.ctor()