using System;using System.Collections.Generic;using System.Text;using System.Reflection;namespace learn.MyReflector...{ public class Task ...{ private int m_id; private DateTime m_arrtime; private string m_name; public int Id ...{ get ...{ return m_id; } set ...{ m_id = value; } } public DateTime ArrTime ...{ get ...{ return m_arrtime; } set ...{ m_arrtime = value; } } public string Name ...{ get ...{ return m_name; } set ...{ m_name = value; } } public override string ToString() ...{ return "learn.MyReflector.Task"; } } public class MyReflectorTest ...{ public void Start(string clsname,object tarobj) ...{ Assembly asm = Assembly.GetExecutingAssembly(); System.Type tasktype = asm.GetType(clsname); PropertyInfo[] proinfo = tasktype.GetProperties(); System.Console.WriteLine("取出属性值"); foreach (PropertyInfo pi in proinfo) ...{ System.Console.WriteLine(pi.Name); } foreach (PropertyInfo pi in proinfo) ...{ System.Console.WriteLine( pi.GetGetMethod().Invoke(tarobj, new object[] ...{ }).ToString() ); } } }} MyReflector.Task mytask = new learn.MyReflector.Task(); mytask.ArrTime = DateTime.Now; mytask.Id = 120; mytask.Name = "test"; MyReflector.MyReflectorTest tp = new learn.MyReflector.MyReflectorTest(); tp.Start(mytask.ToString(), mytask); string bb = System.Console.ReadLine();