using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
namespace WebApplication2 {
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
user u = new user() { name = "zhangsan", age = 33, money = new List<int>() {1,2,3,4,5 } };
string aa=Server.MapPath("/user.cs");
string bb = Assembly.LoadFile(Server.MapPath("/bin/WebApplication21.dll")).FullName.ToString();
string cc= this.GetType().Assembly.FullName.ToString();
Type t = typeof(user);
FieldInfo[] fields =t.GetFields (BindingFlags.Public);
System.Text.StringBuilder parms = new System.Text.StringBuilder();
parms.Append("age");
parms.Append("name");
parms.Append("hh");
Dictionary<string, FieldInfo> dic = new Dictionary<string, FieldInfo>();
fields.ToList().ForEach(c=>dic.Add(c.Name,c));
foreach (FieldInfo field in fields) { FieldInfo f = field; object newValue= f.GetValue(u); f.SetValue(u, newValue); } } } }