When the game first all the highscore points are set to 0 and “empty”. I’m using a dictionary to keep the score and name together so how come when I put it into a for statement it doesn’t like the variables being the same? And since it happens would it be best to use a dictionary especially if two scores end up being exactly the same?
for(int i = 0; i < 6; i++)
{
highscoreList.Add(0, "empty");
}
@LemonCore56 There are some ways to update add/update/read values in a dictionary.
This might be the simplest form that you can retry in my opinion.
And to answer your question “why you cannot call Add(0,“empty”) multiple times”, it is not allowed is because dictionary data structure does not allow you to add key-value pairs with duplicated keys. To demonstrate, if you have a contact list in your phone and you created 2 contacts with different numbers but you named both of them as “Adam”, the next time when you ask your friend to find Adam’s number, your lucky friend will of course get confused whether which Adam you are looking for.
However, in your use case of dictionary, I suppose you can update it using the following code.