I need to change an array cell object which I get from a GetCell method. When I try changing the received object, it does not change the original one.
This is how it looks in code:
// 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]
What am I doing wrong here?
You aren’t changing the received object.
Instead, you’re changing a variable, which used to hold the received object, to hold a brand new object instead.