0
我想知道是否有可能使用mvc web api返回泛型類型。mvc web api get方法返回泛型類型?
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);
}
}
沒關係,你可以例如返回列表
我想知道爲什麼你不試試它? – user2674389