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?

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

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.

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

Can happen to us all, you tell me;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.