无法在LIST中增加 [英] Unable to increment in LIST

查看:88
本文介绍了无法在LIST中增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一份清单。在我的列表中,我只有1条记录。我想在列表中添加增量计数器。如果用户输入5个值,则相同的记录将显示5次。



1印度

2印度

3印度

4印度

5印度





示例:IF值NdPlettes = 4.我的列表将显示4次。

如果NdPlettes的值= 5.我的列表将显示5次



现在我得到的结果如下:

5印度

5印度

5印度

5印度

5印度



我尝试过:



Hi Everyone,

I am having a list. In my list I have only 1 record.I want to add an increment counter in a list. If user enter 5 value the same recor will be display 5 times.

1 INDIA
2 INDIA
3 INDIA
4 INDIA
5 INDIA


Example: IF value of NdPlettes= 4. my list will display 4 times.
IF value of NdPlettes= 5. my list will display 5 times

now I am getting result like:
5 INDIA
5 INDIA
5 INDIA
5 INDIA
5 INDIA

What I have tried:

int index = 1;
               generateSeqNumber();
               foreach (var ProdSelection in ClientImpressionProdSelection)
               {
                   if (index <= InputProduct.NdPlettes)
                   {
                       ProdSelection.Sequence = Convert.ToInt32(GenResult);
                       ProdSelection.Number = index;
                       ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
                       ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
                       ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
                       ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
                       ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
                       ProdSelection.AQP = InputProduct.AQP;
                       ProdSelection.Produit = InputProduct.Produit;
                       ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
                       ProdSelection.NdShipment = InputProduct.NdShipment;
                       ProdSelection.NdLot = InputProduct.NdLot;
                       ProdSelection.Cdate = InputProduct.Cdate;
                       ProdSelection.PoidsNet = InputProduct.PoidsNet;
                       ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
                       ProdSelection.NbrPallet = InputProduct.NdPlettes;
                       ProdSelection.Material = InputProduct.Material;
                       ProdSelection.CodClient = InputProduct.CodClient;
                       ProdSelection.CodPackaging = InputProduct.CodPackaging;
                       ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
                       index++;
                       GetClientImpressionProductSel.Add(ProdSelection);
                   }

推荐答案

你的循环处理所有记录 - 但它只处理那里的记录。如果你想多次处理记录,那么你还需要一个外部循环:

Your loop processes all records - but it only processes records that are there. If you want to process records multiple times, then you will need an external loop as well:
while (index <= InputProduct.NdPlettes)
{
   foreach (var ProdSelection in ClientImpressionProdSelection)
   {
       if (index++ > InputProduct.NdPlettes) break;
       ProdSelection.Sequence = Convert.ToInt32(GenResult);
       ProdSelection.Number = index;
       ProdSelection.ClientDestinataire = InputProduct.ClientDestinataire;
       ProdSelection.LieuDeLivraison = InputProduct.LieuDeLivraison;
       ProdSelection.CodeProduitClient = InputProduct.CodeProduitClient;
       ProdSelection.CodeCouleurClient = InputProduct.CodeCouleurClient;
       ProdSelection.CodeFournisseurEMPourClient = InputProduct.CodeFournisseurEMPourClient;
       ProdSelection.AQP = InputProduct.AQP;
       ProdSelection.Produit = InputProduct.Produit;
       ProdSelection.RefFournisseur = InputProduct.RefFournisseur;
       ProdSelection.NdShipment = InputProduct.NdShipment;
       ProdSelection.NdLot = InputProduct.NdLot;
       ProdSelection.Cdate = InputProduct.Cdate;
       ProdSelection.PoidsNet = InputProduct.PoidsNet;
       ProdSelection.PoidsBrut = InputProduct.PoidsBrut;
       ProdSelection.NbrPallet = InputProduct.NdPlettes;
       ProdSelection.Material = InputProduct.Material;
       ProdSelection.CodClient = InputProduct.CodClient;
       ProdSelection.CodPackaging = InputProduct.CodPackaging;
       ProdSelection.CoefNetBrut = InputProduct.CoefNetBrut;
       GetClientImpressionProductSel.Add(ProdSelection);
   }
}


在循环内部创建 ProdSelection 你有,并为每次迭代创建一个。



祝你好运
Put creation of the ProdSelection inside of the loop that you have, and created one for each iteration.

Good luck


这篇关于无法在LIST中增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆