Ok, so I'm having an issue with ArrayList. I seem to be unable to access the arraylist using an index. Look at the following example: (ps, Core.Score is a struct)
ArrayList HighScoreList = new ArrayList(); Core.Score tmpScore = new Core.Score(); tmpScore.Name = "ABRAKADABRA"; tmpScore.HighScore = 33234; tmpScore.yOffset = 0.3f; HighScoreList.Add(tmpScore);
So, if I now access this Highscorelist using a foreach loop, like so: foreach(Core.Score score in HighScoreList) { highscoreName.guiText.text = score.Name; } This works fine, I get ABRAKADABRA printed nicely.
However, using a simple index does not work at all.. I would have though i should be able to write: highscoreName.guiText.text = HighScoreList[0].Name;
But, it doesn't find the struct in index 0. I get this error: "Object" does not contain a definition for "Name".
So, what's going on here? Some hint would be fantastic :)
Thanks.
Kjetil