我想知道是否可以使用 mvc web api 返回泛型类型。
eg can I retrun List<T> and NOT List<int> or is this too crazy?
// adding a little more context
// Controller
IRepoClassInterface repo = new ReopClassWorker();
public List<T> Get<T>(string date, string chartName)
{
switch(chartName)
{
case "myCoolChartBrah":
return repo.Get<MyListType>(date);
case "anotherChart":
return repo.Get<AnotherListType>(date);
}
}