0

i made two arrays..belonging to an object that i created Pieces. that object holds more objects (chess pieces).

now i gave it two references..

1) Pieces[,] temp = new Pieces[9, 9];
2) Pieces[,] pieces = new Pieces[9, 9];


now if i do this: temp[1, 1] = null;

the same change will happen in pieces[,] //
pieces[,] will change to null too. why is that?

cant i modify one object type without effecting the other?

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by ddanbe
0

You created two different 2D arrays named temp and pieces each consisting of 81 objects of type Pieces.

0

cant i modify one object type without effecting the other?

Yes you can, somewhere in your code you are setting them to the same reference. Or you've never set any of the values in the first place.

Edited by Momerath: n/a

0

i think what i did was
set temp=pieces;
and then did temp[1,1]=null;
that reference took the other reference and made pieces equal to null. thats where i got wrong.
i am working late, and i lost concentration, i think

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.