【发布时间】:2014-06-13 13:37:40
【问题描述】:
List<ReportDataInfo> Lrdi = new List<ReportDataInfo>();
ReportDataInfo rdi = new ReportDataInfo();
ReportDataInfo RdiMerge=new ReportDataInfo();
string[] AccountTypeCodeCustomArray =
AccountCodeTypeCustom.Split(",".ToCharArray());
string[] SubTypeCodeCustomArray =
SubAccountTypeCodeCustom.Split(",".ToCharArray());
string[] AccountCodeCustomArray = AccountCodeCustom.Split(",".ToCharArray());
for (int i = 0; i < AccountCodeTypeCustom.Length; i++)
{
rdi = ExportDataToCSV.GetLedgerReportData(Globals.GetInt(
AccountTypeCodeCustomArray[i],0),Globals.GetInt(
SubTypeCodeCustomArray[i],0),Globals.GetInt( AccountCodeCustomArray[i],0),
this.CurrentSessionInfo.Company.CompanyCode,
this.CurrentSessionInfo.FinancialYear.StartDate,
this.CurrentSessionInfo.FinancialYear.EndDate);
// Lrdi.Add(rdi);
RdiMerge.Rows.Concat(rdi.Rows);
//RdiMerge.ReportHeading = rdi.ReportHeading;
//RdiMerge.Rows = rdi.Rows;
}
CurrentSessionInfo.ReportData = RdiMerge;
这是我之前尝试过的东西
现在我的问题是 我想合并从 ExportDataToCSV.GetLedgerReportData();
返回的 ReportDataInfo无论从 ExportDataToCSV.GetLedgerReportData(); 返回的任何值,我都被困在这里 我想合并成单个 ReportDataInfo 然后传递给 CurrentSessionInfo.ReportData = RdiMerge;
ReportDataInfo 看起来像
[Serializable]
public class ReportDataInfo
{
public string ReportHeading { get; set; }
public List<ReportColumnInfo> Rows { get; set; }
}
【问题讨论】:
-
List<T>有一个AddRange()方法。你试过吗? -
没有@EladLachmi 的例子对我来说很好
-
msdn.microsoft.com/en-us/library/z883w3dc(v=vs.110).aspx - 关于
List<T>的AddRange的MSDN 页面。这个想法是AddRange采用IEnumerable<T>并将其附加到列表的末尾。这就是你想要的,对吧?还是我误会了?