日期:2014-05-18 浏览次数:20797 次
int i = 0; Type t = i.GetType(); PropertyInfo[] props = t.GetProperties();//public属性集合 MethodInfo[] methods = t.GetMethods();//public方法集合
------解决方案--------------------
using System; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Reflection; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { object o = Activator.CreateInstance(Type.GetType("WindowsApplication13.MyClass")); MethodInfo MyMethod = o.GetType().GetMethod("Test"); object[] obj = new object[2]; obj[0] = "ZengHD"; MyMethod.Invoke(o, obj); MessageBox.Show(obj[1].ToString()); } } public class MyClass { public void Test(string s,out string value) { value = "bbbbbbbbbbbbbbbbbbbbbb"; MessageBox.Show(s); } } }