2009-10-30 46 views

回答

5

Reflector是一个很好的方法去做这个。

转到查看/选项/优化,并选择“无”,以便它不会试图找出C#原来是什么。

例如,这个小应用程序的Main方法:

using System; 

class Test  
{ 
    static void Main() 
    { 
     string other = "hello"; 
     Foo (x => new { Before = other + x, After = x + other }); 
    } 

    static void Foo<T>(Func<int, T> func) {} 
} 

在反编译:

private static void Main() 
{ 
    <>c__DisplayClass1 class2; 
    class2 = new <>c__DisplayClass1(); 
    class2.other = "hello"; 
    Foo(new Func<int, <>f__AnonymousType0<string, string>>(class2.<Main>b__0)); 
    return; 
} 

,然后你在<>c__DisplayClass1外观和<>f_AnonymousType0更多细节等

2

您可以使用ildasm来查看编译器的MSIL输出。

1

如果您想在.NET框架中调用CLR方法时想进入内部和发生什么,还有另外一种方法。

如果您使用VS 2008,您甚至可以调试.net框架源代码。为此,您需要安装Microsoft source reference server hotfixes ..

而且Shawn Burke得到了一个很好的职位(一步一步的指导)来配置这个东西..

只要给一个尝试..

相关问题