Let's say I have this 2 classes:
public class BlockBuilding
{
private List<Room> rooms;
...
public class Room
{
private List<Chair> chairs;
....
Then I declare an 2D array variable and assign values:
BlockBuilding[,] bB= new BlockBuilding[2,1];
Room room = new Room();
BlockBuilding b1 = new BlockBuilding();
BlockBuilding b2 = new BlockBuilding();
b1.getRooms().Add(room);
b2.getRooms().Add(room);
bB[0,0] = b1;
bB[1,0] = b2;
Chair c1 = new Chair();
Chair c2 = new Chair();
bB[0,0].getRooms()[0].getChairs().Add(c1);
bB[1,0].getRooms()[0].getChairs().Add(c2);
Assuming all the necessary data is there and there is no NullException issue, when I tried to display the chairs in bB[0,0] and bB[1,0], surprisingly they both contained c1 and c2 while each of them should only contain one chair.
All above is similar code structure to my codes and no disclosure of my codes is allowed due to disclosure agreement restrictions. I have been haunted by this bug for weeks. Any help would be greatly appreciated!