私は2つのリストを持っています。それらを1つのリストにまとめたい。
問題は、2 つのリストの 1 つが 1 つのカウント サイズだけであることです。
firstList.Count = 1
2 番目のリストのサイズは 2 です。
secondList.Count = 2
したがって、これらのリストのボットを 1 つのリストに結合したいと考えています。
megaList => firstList {0, Empty},
secondList {0 , 2}
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; }
}