????3.????????ajax??洫??????????get?????????post????????JSON??????????
??????????????get??????????Name=xx&Age=xx???????????????????????
????Dictionary<string?? object> dic = new Dictionary<string?? object>();
????dic.Add("Id"??100);
????dic.Add("Name"?? "keso");
????dic.Add("Group"?? "?????");
??????????????
public static T ConvertDic<T>(Dictionary<string?? object> dic)
{
T model = Activator.CreateInstance<T>();
PropertyInfo[] modelPro = model.GetType().GetProperties();
if (modelPro.Length > 0 && dic.Count() > 0)
{
for (int i = 0; i < modelPro.Length; i++)
{
if (dic.ContainsKey(modelPro[i].Name))
{
modelPro[i].SetValue(model?? dic[modelPro[i].Name]?? null);
}
}
}
return model;
}
???????????
????User user = ConvertDic<User>(dic);