Adding items to a LIST of objects results in duplicate Objects when using a NEW in a Loop

You’ve only created one object, and added it twice. The fact that you modified that object between the first and second add is irrelevant; the list contains a reference to the object you added, so later changes to it will apply.

You need to replace newBol.BillOfLadingNumber = ".."; with newBol = new BillOfLading("..");

Leave a Comment