如题,谢谢!

解决方案 »

  1.   

    .net下不是直接可以看吗用类视图等等那些功能
      

  2.   

    static void Main(string[] args)
            {            System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFile(
                    @"C:\ConsoleApplication1\ClassLibrary1\bin\Debug\ClassLibrary1.dll");
                Type[] types = assembly.GetTypes();
                foreach (Type type in types)
                {
                    Console.WriteLine(type.Name);                System.Reflection.FieldInfo[] fis = type.GetFields();
                    foreach (System.Reflection.FieldInfo fi in fis)
                    {
                        Console.WriteLine(fi.Name);
                    }
                    
                    //... 方法, 属性 类似
                }            Console.ReadKey();        }
      

  3.   

    谢谢楼上的各位兄弟的回答,非常感谢。是我没表达清楚,不好意思。我是想读入一个C#中的cs文件,从中分析出类名,字段名,属性名,方法名等,该怎么做呢?
      

  4.   

    参考资料1。编译原理 
      计算机系的教科书2。C#语言式样 
      vs2005安装目录下\Microsoft Visual Studio 8\VC#\Specifications\1041
      

  5.   

    打MSDN,输入反射,
    就有你想要的
      

  6.   

    确实可以先编译再用反射 但这样肯定效率差 而且会得到许多不想要的东西
    这个应该类似词法分析器 逐行读取 记录当前的namespace, class name, 并根据格式判断当前行是field 还是method 还是property 大概就这样吧
      

  7.   


    1.词法分析器 逐行读取 记录当前的namespace, class name, 并根据格式判断当前行是field 还是method 还是property2.反射