我有 2 个列表。我想将它们组合成 1 个列表。
问题是两个列表之一只有一个计数大小
firstList.Count = 1
而第二个列表的大小是两个:
secondList.Count = 2
所以我想将这些列表中的机器人组合成 1 个列表。
megaList => firstList {0, Empty},
secondList {0 , 2}
我这样做的代码不起作用,因为这两个列表的大小不同。我该如何解决?
List<QuestionAndResponses> megaList = new List<QuestionAndResponses>();
for (var i = 0; i < firstList.Count(); i++)
{
megaList.Add(new QuestionAndResponses()
{
Responses = new List<Response>(firstList[i].Response),
Questions = new List<Question>(secondList[i].Questions)
});
}
我的模型看起来像这样:
public class QuestionAndResponses
{
public PreScreener Question { get; set; }
public PreScreenerResponse Response { get; set; }
}