B继承A
List<B> list=new List<B>(); myfun(list.Cast<A>() as List<A>);
返回值:
public override List<A> Load() { List<B> plnTaskList = new List<B>(); return plnTaskList.Cast<A>() as List<A>; }
另一种方式:
public override List<Task> Load(string projectIds) { string sql = ""; DataTable dt = Conn.GetDataTable(sql); if (dt != null && dt.Rows.Count > 0) { return dt.ToModel<PlnTask>().ConvertAll(s => (Task)s); } else { return null; } }
调用:
PlnTaskService plnTaskService = new PlnTaskService(linkId); List<PlnTask> plnTaskList = plnTaskService.Load(projectIds).ConvertAll(s=>(PlnTask)s);