我有一个StockMultibuy项目列表,正在构建这些项目的列表.列表中的某些项目我希望具有与现有项目不同的属性,因此我尝试创建项目的新实例,更改了我想要的属性,然后将其添加到列表中.我没想到会更新列表中已有的项目.这是预期的行为吗?我能做些什么来克服这个问题吗?
谢谢
StockMultibuy aNewItem = StaticLists.GetStockMultibuyForBarcode(sBarcode);
// If we've got enough items to qualify, then add a free item
if (Reward.StockItemsTaken.Count % (Reward.FreeWhenQualified + Reward.QualifyingQty)
== Reward.QualifyingQty)
{
aNewItem.PromoPrice = 0;
}
// Save this for later so that we know we've added a regular item
else
{
aNewItem.PromoPrice = Convert.ToDecimal(aNewItem.Sell);
}
Reward.StockItemsTaken.Add(aNewItem);
Run Code Online (Sandbox Code Playgroud) c# ×1