This question is related to the code sample in the answer here (https://stackoverflow.com/a/70694640/2287576).
I now have this constructor:
public List<MSAHistoryItemStudent>[] StudentItems { get; set; }
public MSAHistoryWeek()
{
TalkItems = Enumerable.Range(1, 6).Select(x => new MSAHistoryItemTalk()).ToList();
Teaching = Enumerable.Range(1, 3).Select(x => string.Empty).ToList();
StudentItemStudyNumbers = Enumerable.Range(1, 5).Select(x => string.Empty).ToList();
StudentItemDescriptions = Enumerable.Range(1, 5).Select(x => string.Empty).ToList();
StudentItems = new List<MSAHistoryItemStudent>[]
{
new List<MSAHistoryItemStudent>(),
new List<MSAHistoryItemStudent>(),
new List<MSAHistoryItemStudent>(),
};
foreach(var studentitems in StudentItems)
{
for(int i = 0; i < 5; i++)
{
studentitems.Add(new MSAHistoryItemStudent());
}
}
}
I can't work out the Enumerable.Range
approach to pre-create StudentItems
how I want:
- I want an array of 3
List<MSAHistoryItemStudent>
. - I want each of these arrays to have 5
MSAHistoryItemStudent
elements.