Say I have 3 strings in a List (e.g. "1","2","3").
Then i want to reorder them to place "2" in position 1 (e.g. "2","1","3").
I am using this code (setting indexToMoveTo to 1):
listInstance.Remove(itemToMove);
listInstance.Insert(indexToMoveTo, itemToMove);
This seems to work BUT I am occasionally getting strange results; sometimes the order is incorrect or items from the list are getting deleted!
Any ideas? and does List guarantee order?
Related:
Does a List guarantee that items will be returned in the order they were added?