2011年5月19日
摘要: 命名空间引入using System.Reflection;首先定义一个类public class Dog { public string DogName { get; set; } }类的实例:Dog mydog=new Dog();获取实例类型Type t = typeof(Dog);或者Type t = mydog.GetType();有了这个类型t,就可以利用反射对这个实例为所欲为了:设置属性值:t.GetProperty("DogName").SetValue(mydog, "pet", null);获取属性值:t.GetProperty(&q 阅读全文
posted @ 2011-05-19 16:30 一直在前进 阅读(911) 评论(0) 推荐(0) 编辑