using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; namespace ReflecttionTest { class Program { static void Main(string[] args) { TestClass testClass = new TestClass(); MethodInfo methodInfo = typeof(TestClass).GetMethod("fun1"); methodInfo.Invoke(testClass, new object[] { "haha" }); PropertyInfo propertyInfo = typeof(TestClass).GetProperty("Num"); propertyInfo.SetValue(testClass, 5,null); Console.WriteLine("{0}", propertyInfo.GetValue(testClass,null)); } } class TestClass { public void fun() { Console.WriteLine("xuxu"); } public void fun1(string str) { Console.WriteLine("{0}",str); } public int Num { get; set; } } }