Move object to different point in array

Got a 2D array of GameObjects containing every unit in the game, what I want to do is, when the unit moves, I want it to move to that position in the array, so if it moves to right by 1, the position won’t be [1,1] but [2,1].

myArray[2,1] = myArray[1,1];
myArray[1,1] = null;

Thought about that, figured it wouldn’t work. Thanks!
EDIT:
Yep, it works.