我做过类似的事情;
var list; //-> i want to declare this list once time
if (gvd.ID.Equals("gvAccountSetup"))
{
ClsAccountHead AccountHead = new ClsAccountHead();
AccountHead.CampusId = cmbAccCampus.SelectedValue.ToInt32();
// here i want to intialize the same list with other type
list = new List<ClsAccountHead>();
list = AccountHead.AccountHeadListByCampusId(PageIndex + 1, PageSize);
}
else if (gvd.ID.Equals("gv_AccSubHead"))
{
ClsAccountSubHead AccountSubHead = new ClsAccountSubHead();
AccountSubHead.HeadId = cmbSrchAccHead.SelectedValue.ToInt32();
// here i want to intialize the same list with another type
list = new List<ClsAccountSubHead>();
list = AccountSubHead.SubHeadGetListByHeadIdWithPaging(PageIndex, PageSize);
}
所以,我的问题是我如何编写一个声明一次的列表(通用),然后我可以用它传递多重类型;