复制放置在项目列表中的对象并更改重复对象的属性的最佳方法是什么?如何复制列表中的对象并更新重复对象的属性?
我想继续通过以下方式: - 根据需要(n次)克隆找到对象多次 - - 由“裁判” +“文章” 获取列表对象中删除对象中找到 - 添加列表中的克隆
您认为如何?
一个具体的例子:
Private List<Product> listProduct;
listProduct= new List<Product>();
Product objProduit_1 = new Produit;
objProduct_1.ref = "001";
objProduct_1.article = "G900";
objProduct_1.quantity = 30;
listProducts.Add(objProduct_1);
ProductobjProduit_2 = new Product;
objProduct_2.ref = "002";
objProduct_2.article = "G900";
objProduct_2.quantity = 35;
listProduits.Add(objProduct_2);
期望的方法:
public void updateProductsList(List<Product> paramListProducts,Produit objProductToUpdate, int32 nbrDuplication, int32 newQuantity){
...
}
调用方法例如:
updateProductsList(listProducts,objProduct_1,2,15);
等待结果:
替换跟随对象:
ref = "001";
article = "G900";
quantite = 30;
通过:
ref = "001";
article = "G900";
quantite = 15;
ref = "001";
article = "G900";
quantite = 15;
的算法是正确的?你有一个想法的方法实施“updateProductsList”
谢谢您的帮助。
这是C#,对不起!我已经删除了java标志。 – TimeIsNear 2010-06-06 14:08:33