- Home /
List getting reversed?
Hi,
I have a list of a list of buttons and I've noticed that after I initially add items to the list, the order of them can get reversed. This is actually very important to my game and greatly affects some parts.
I have printed out the contents when they are first added, and then I have printed out the contents when I use them next. And they are reversed. As far as I know, I am not altering the list in the meantime.
Has anyone come across this before?
UPDATE:
After a bit of testing I have found out that the list isn't actually getting reversed, but some elements are being moved around
First time adding to list:
Second time checking:
This is the first time I am printing them out
And this is the second time (identical code)
And these are the results
First time:
Second time:
Sorry for putting these into two comments, but it wouldn't let me post all of this in one comment for some reason
Do not post code in images. This make it impossible to refer to certain lines without retyping your code. UA has
code highlighting
so use it. Also this information should be part of the question and not a comment to the question. Also you should include how buttons
is actually declared-
Have you checked all references to buttons in your code? Are you sure you never change anything? If you use Visual Studio or $$anonymous$$onoDevelop you can simply rightclick your "buttons" variable and select "Find all references" (might be named different). This should give you a list of all positions in your code where you read or write to this variable.