So basically, I have an arraylist of type section. section is a class with a couple of properties, a count of the panels in the section, a name of the section, a weight of the section, an area of the section, and an arraylist of type Piece.
Piece is a class with properties for qty, length, name, description, cost, and the way its measured (per piece or per linear foot).
So each section is made up of a bunch of pieces.
The basic flow of the code is something along the lines of:
-get the list of the sections entered (there can be 1-12 sections, based on user input).
-initialize the sections with a list of Pieces that has length/qty/etc set to zero.
-add the sections to the sections' arraylist
-read an inport file associated with each section, parse through it for panel count, weight, area, etc, and update the section's arraylist.
Below is the code for that last step (reading the file is it's own function).
What is happening, is after the 4th line (readFile()), my tempSectionB was updated correctly. It has the right weight, area, and piece list. Loop through to the next section, and again, it has the correct section object for the import file. However, after adding it to the section's list, it overwrites the first section in the list's piece list. Everything else in the first and second section is different/valid (they have their own weight, area, panels, etc), but both now have the exact same piece list. Despite on the previous loop it having a different list.
So, first loop we have a piece list with a total qty of the pieces is, lets say 100. Second loop we have a piece list with a total qty of the pieces is 200. Then, magically, our FinalSectionList both have the qty of 200.
foreach(section tempSection in SectionsList)
HtmlInputFile uploadedFile = tempSection.getFileForSection();
string fileLoc = Server.MapPath("tempfiles//" + uploadedFile.Value.Substring(uploadedFile.Value.LastIndexOf("\\")+1));
section tempSectionB = readFile(fileLoc, tempSection);
Any ideas why the piece lists are overwriting each other? We can't figure it out.