解决方案 »

  1.   

    CustomerObj.GetType().GetProperty("id").SetValue(xxxxxx)
      

  2.   

    反射有好几种写法,我与你分享一下我的写法:
    string method = Request.Params["method"].ToString();
                                        method = method.Replace(".", "_");
                                        string classfullname = "JSTRest.RequestModule." + method;
                                        IResourceMethod irm = Type.GetType(classfullname).Assembly.CreateInstance(classfullname, true) as IResourceMethod;
                                        if (irm == null)
                                        {
                                            ErrorInfo.SetErrorInfo("000", formattype);
                                        }
                                        PropertyInfo[] properties = Type.GetType(classfullname).GetProperties();
                                        for (int i = 0; i < properties.Length; i++)
                                        {
                                            for (int j = 0; j < Request.Params.Count; j++)
                                            {
                                                if (Request.Params.GetKey(j).Trim() == properties[i].Name)
                                                {
                                                    string val = Request.Params[j].ToString();
                                                    val = HttpUtility.UrlDecode(val);
                                                    properties[i].SetValue(irm, val, null);
                                                }
                                            }
                                        }
      

  3.   

    SetValue(object,object)设置值
    GetValue(object)获取值