反射遇到的小问题,高手来看看!
<%@ Page Language="C#" %><script runat="server"> public void Page_Load(object sender, EventArgs e) { System.Collections.Generic.List<string> source = new System.Collections.Generic.List<string> { "A", "B", "C", "D", "E" }; foreach (object data in source) { Type type = data.GetType(); foreach (System.Reflection.PropertyInfo property in type.GetProperties()) { object propertyValue = property.GetValue(data, null); string value = (propertyValue == null) ? string.Empty : propertyValue.ToString(); Response.Write(property.Name + " = " + value + ","); } Response.Write("<br />"); } }</script>