我需要更改从GetCell方法获得的数组单元格对象。当我尝试更改收到的对象时,它不会更改原来的对象。为什么对象引用不能引用预期的对象?
这是它的外观在代码:
// this is in MyClass
A[,] arr = new A[100,500];
// this is in main class
MyClass GetAAt(Point p) { return myClass.arr[p.X,p.Y]; }
var a = GetAAt(new Point(23,45));
a = new A(); // this only changes the local `a` but not the arr[23,45]
我在做什么错在这里?
那么我该怎么做我想做的事? – user1306322
@ user1306322:你不能。 – SLaks
你仍然可以解决问题,你只需要努力一点就可以了。 [看我的回答](http://stackoverflow.com/a/13298796/1159478)为例。 – Servy