Array.Resize create a new array and then copies element of old one into new one, However it also has a shortcut, so if you resize to the same size, method will not create a new array. So while function copies a reference to original array, after the first Resize locally stored reference is replaced with a new one. that is why first Reverse works on original array, while second one alters only new ones, locally stored COPY of the original array. Adding
! Array.Resize(ref A, A.Length + 1); ! Array.Resize(ref A, A.Length - 1); !
Will replace reference to the original, while not changing data and will pass the Array.Resize shortcut. So all further operations will be performed with a copy of the array. Important to note that Array.Resize copies only one level of array and multi-dimensional arrays will still be altered. That is why same line of code can be added for each iteration
Btw this is code should not be used in any way, unless you want to sabotage something.