获取对象字段的值
static void Main(string[] args) { Person ps = new Person(); ps.Name = "CTZ"; ps.Age = 21; Console.WriteLine(ps.GetValue("Name")); Console.WriteLine(ps.GetValue("Age")); Console.Read(); } public class Person { public string Name { get; set; } public int Age { get; set; } public object GetValue(string propertyName) { return this.GetType().GetProperty(propertyName).GetValue(this, null); } }