对载入AppDomain的程序集的反射

+展开
-C#
///对载入AppDomain的程序集的反射
///

using System;
using System.Reflection;

class wangjun
{
    public static void Main()
    {
        //得到当前正在执行程序集的对象
        Assembly assembly = Assembly.GetExecutingAssembly();
        //从程序集中得到类型,并遍历类型
        foreach (Type type in assembly.GetTypes())
        {
            //输出类型名
            Console.WriteLine("class is {0}",type);
            //从类型中得到方法名,并遍历方法
            foreach (MethodInfo method in type.GetMethods())
            {
                //输出方法名
                Console.WriteLine("method is {0}",method);
                //从方法名中得到签名(方法的参数),并遍历签名
                foreach (ParameterInfo parameter in method.GetParameters())
                {
                    //输出签名
                    Console.WriteLine("parameter is {0}",parameter);
                }
            }
        }
    }
}

来源:http://2sws.blog.163.com/blog/static/179102492009843458783/

加支付宝好友偷能量挖...


评论(0)网络
阅读(105)喜欢(0)Asp.Net/C#/WCF