C# 反射

个人肤浅理解,反射实际上就是得到程序集中的属性和方法.
实现步骤:
1,导入using System.Reflection;
2,Assembly.Load("程序集")加载程序集,返回类型是一个Assembly
3,   foreach (Type type in assembly.GetTypes())
            {
                string t = type.Name;
            }
   得到程序集中所有类的名称
4,Type type = assembly.GetType("程序集.类名");获取当前类的类型
5,Activator.CreateInstance(type); 创建此类型实例
6,MethodInfo mInfo = type.GetMethod("方法名");获取当前方法
7,mInfo.Invoke(null,方法参数);
原文地址:https://www.cnblogs.com/cpetcoandy/p/2182090.html