Why is argument out of range?
Heres a code snippet
tempBoard is an array of strings, which reads all lines from a txt file i have. the layout of the txt is:
Name
Score
Name
Score
etc..
When i try to add data to a list called Leaderboard, using the tempBoard array, it gives the error "Argument is out of range", and ive no idea why?
for example, when i =0, i*2 will equal 0, and (i*2)+1 will equal 1. in the example below, when i gets to 3, i*2 will equal 6, and (i*2)+1 will equal 7, which should work given the length tempBoard is 8 (shown below).
What is happening? thanks in advance
Error is on tempBoard or $$anonymous$$erBoard? How did you initialise $$anonymous$$erBoard?
honestly not sure, the error is on the line that reads;
$$anonymous$$erBoard[i].playerName = tempBoard[(i*2)+1];
$$anonymous$$erboard is a list of the class HighScore
List $$anonymous$$erBoard = new List();
Answer by NeilH176 · Nov 08, 2017 at 02:00 PM
Used LeaderBoard.Add() instead, works now!
Your answer
Follow this Question
Related Questions
Unknown Argument Out of Range Index Error On Card Game 1 Answer
ArguentOutOfRangeException: Argument is out of range. Parameter name:index 1 Answer
Destroy GameObject after certain amount is reached? 1 Answer
Cant figure out how to implement a inventory system 1 Answer
Simple way to access data of different types within a nested array? 0 Answers