用反射调用实例方法和静态方法

   Assembly assembly = Assembly.Load("bll");

            Type type = assembly.GetType("bll.Class2");  

            object obj = Activator.CreateInstance(type); //创建类的实例

            bll.Class2 c2 = (bll.Class2)obj;  

            this.Label1.Text = type.InvokeMember("aa", BindingFlags.InvokeMethod, null, c2, null).ToString();  //调用实例方法

            this.Label1.Text = type.InvokeMember("bb", BindingFlags.InvokeMethod, null, null, null).ToString();//调用静态方法



你可能感兴趣的:(静态方法)