I found a curious effect in some code I wrote that I don't understand. I found a workaround but I'd like to know why the original code doesn't work as expected.
So populating a jagged array, I tried to define each cell individually. This resulted in 10 copies of the last array defined. From this code:
for (int i = 0; i < 10; i++)
{
serialisableHighScores.scores[i][0] = _highScores[i].date;
serialisableHighScores.scores[i][1] = _highScores[i].score;
serialisableHighScores.scores[i][2] = _highScores[i].questionsAsked;
}
Whereas when using a single dimension array as an intermediate, the data saved as expected. By which I mean there were 10 unique arrays saved in the jagged array. From this code:
for (int i = 0; i < 10; i++)
{
int[] scoreArray = { _highScores[i].date, _highScores[i].score, _highScores[i].questionsAsked };
serialisableHighScores.scores[i] = scoreArray;
}