【发布时间】:2016-05-06 07:20:46
【问题描述】:
我将 T 作为参数传递,我遇到了这个构建错误。
这是我的要求
public JsonResult SetGridProperties(Response<T> res)
{
res.ShowFilterRow = (!res.ShowFilterRow);
return Json(true, JsonRequestBehavior.AllowGet);
}
这是我的响应类
public class Response<T>
{
public bool Status { get; set; }
public string Message { get; set; }
public T Data { get; set; }
public List<T> DataList { get; set; }
public MessageTypes MessageType { get; set; }
public bool ShowFilterRow { get; set; }
public bool AllowGroup { get; set; }
}
请指导我如何使用此响应类作为参数,动态实体对象为“T”。
【问题讨论】:
-
尝试在方法定义中指定 T。 eg.public JsonResult SetGridProperties
(Response res){//代码} -
查看答案!
标签: asp.net-mvc parameters extension-methods jsonresult actionmethod