1
我做過類似的事情;如何在C#中使用通用列表來實現多用途?
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);
}
所以,我的問題是我怎樣寫一個列表(通用)這是聲明瞭一次,然後我可以通過multipe型與它;
如何使TagInterface ...? –
Plz可以給我發送Interface –
@ShahidIqbal我修改了答案 – 2013-03-29 06:07:03