标签:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CacheTest { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { List<Customer> list = new List<Customer>() { new Customer() { ID = "A", Name = "AA", TaxNo = 1 }, new Customer() { ID = "B", Name = "BB", TaxNo = 2 }, new Customer() { ID = "C", Name = "CC", TaxNo = 3 } }; foreach (var item in list) { string name = item.GetType().InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, item, null) as string; Response.Write(name + "\n"); } } } public class Customer { public string ID { get; set; } public string Name { get; set; } public int TaxNo { get; set; } } }
标签:
原文地址:http://www.cnblogs.com/wolfocme110/p/5628785.html