In C #, I have an Array from MenuItem. I am trying to swap two objects at index 2 and index 3 of an array without success using the following code:
MenuItem Temp = Items[2];
Items[2] = Items[3];
Items[3] = Temp;
There must be a reason why the second and third lines do not work in C #, which I still can not understand. Can anyone clarify this a bit more? Should I go deeper and change each property in objects individually?
Edited - Sorry. Looks like I messed up the code, trying to clear it up for publication. Fixed now.
Actual code:
MenuItem TempButton = MenuItems.Items[SelectedButton.CountId];
MenuItems.Items[SelectedButton.CountId] = MenuItems.Items[SelectedButton.CountId + 1];
MenuItems.Items[SelectedButton.CountId + 1] = TempButton;
MenuItems.Items is an array of MenuItem
Looking at the clock that I posted on MenuItems.Items, nothing happens on Line 2 or 3.
The property MenuItems.Itemshas get and set functions that can cause a problem ... Next it explores ...